Perl monks 的 快速回复
| on Jun 20, 2019 at 11:39 UTC ( #11101620=perlquestion: print w/replies, xml ) | Need Help?? |
jimyokl has asked for the wisdom of the Perl Monks concerning the following question:
I just started learning Perl for several days.I sow some codes below, what is the type of $data, is it array or a hash? There are so many nests. Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| Re: what is the variable type of $data = { by Anonymous Monk on Jun 20, 2019 at 12:06 UTC |
|
|
In this piece of code, { There are two syntactically different ways to access a hash by reference: $data->{$key} (the arrow operator, ->) and ${$data}{$key} (wrap the reference in {} - where you could also put the name of the hash if it had a name). Both ways take $data, try to dereference it, access the underlying hash and return the scalar value referenced by key $key. If $data does not contain a hash reference, an exception will be raised (but if $data is undef, an anonymous hash may be created automatically and a reference to it may be stored inside $data - see autovivification). See perlreftut and perldsc for more info. |
[reply] [d/l] [select] |
|
Re^2: what is the variable type of $data = { by you!!! on Jun 20, 2019 at 12:14 UTC |
|
|
Reputation: 1
|
[reply] [edit] [/msg] |
|
Re: what is the variable type of $data = { |
|
|
++ To AnonyMonk, $data is a reference to a hash, that itself contains hashrefs (eg the value at a10 is a hashref). One way to test for that is to use ref, that will return 'HASH' in this case, or Scalar::Util's reftype, that is guarranted to always return 'HASH' even if the reference is blessed (turned into an object). So you can check that ref $data eq 'HASH' |
[reply] [/msg] [d/l] |
|
Re^2: what is the variable type of $data = { by you!!! on Jun 20, 2019 at 12:21 UTC |
|
|
Reputation: 0
|
[reply] [edit] [/msg] |
|
Re: what is the variable type of $data = { |
|
You might be confused because hashes and arrays have to incarnations in Perl
Hashes consist of key => value "string" => scalar
To realize nested hashes you need to put a hash reference into the value slot. That's what's happening here. See perldsc for more examples. HTH :) Cheers Rolf °) my wording |
|
what is the variable type of $data = {by you!!! |
Perl monks 的 快速回复的更多相关文章
- iOS8推送消息的快速回复处理
http://blog.csdn.net/yujianxiang666/article/details/35260135 iOS8拥有了全新的通知中心,有全新的通知机制.当屏幕顶部收到推送时只需要往下 ...
- 【转载】TCP慢启动、拥塞避免、快速重传、快速回复
转载自:TCP慢启动.拥塞避免.快速重传.快速回复 转自:http://blog.csdn.net/itmacar/article/details/12278769 感谢博主的辛勤成果! 为了防止网络 ...
- discuz X2.0教程]教你快速了解Discuz!程序文件功能,修改文件从此不用再求人
x3.x数据字典 http://faq.comsenz.com/library/database/x3/x3_index.htm 先从根目录开始,根目录文件一般都是入口,即执行具体功能的代码一般不在这 ...
- 1.Perl基础系列之WHAT、WHY、HOW
What? Perl,一种功能丰富的计算机程序语言,运行在超过100种计算机平台上,适用广泛,从大型机到便携设备,从快速原型创建到大规模可扩展开发. Why? Perl追求简洁快速地解决问题,可很方便 ...
- idea 插件的使用 进阶篇
CSDN 2016博客之星评选结果公布 [系列直播]零基础学习微信小程序! "我的2016"主题征文活动 博客的神秘功能 idea 插件的使用 进阶篇(个人收集 ...
- idea如何设置类头注释和方法注释
CSDN 2016博客之星评选结果公布 [系列直播]算法与游戏实战技术 "我的2016"主题征文活动 详细:idea如何设置类头注释和方法注释 标签: idea ...
- 高性能MySQL之【第十五章 备份与恢复】学习记录
我们不打算包括的话题: 安全(访问备份,恢复数据的权限,文件是否需要加密) 备份存储在哪里,包括他们应该离源数据多远,以及如何将数据从源头移动到目的地 保留策略.审计 ...
- JAVA 集合 List 分组的两种方法
CSDN日报20170219--<程序员的沟通之痛> [技术直播]揭开人工智能神秘的面纱 程序员1月书讯 云端应用征文大赛,秀绝招,赢无人机! JAVA 集合 List 分组的两种方法 2 ...
- Commons BeanUtils 中对Map的操作
CSDN学院招募微信小程序讲师啦 程序员简历优化指南! [观点]移动原生App开发 PK HTML 5开发 云端应用征文大赛,秀绝招,赢无人机! Commons BeanUtils 中对Map的操作 ...
随机推荐
- Unity3D4.* NGUI制作动态字库
新建一个工程,这个工程必须没有中文路径,否则会不识别字体!!! 首先导入NGUI插件,这里我用的是NGUI 3.0.2版本的. 在Assets 下创建一个文件夹,用来存放接下来的工作文件 . 这里随便 ...
- UVa 11040 Add bricks in the wall (水题递推)
题意:给定一个金字塔,除了最后一行,每个数都等于支撑它的两个数的和,现在给奇数行的左数奇数位置,求整个金字塔. 析:很容易看出来,从下往上奇数行等于 a[i][j] = (a[i-2][j-1] - ...
- J20170426-hm
ジェネリクス Generics 泛型 バルーン balloon 气球 アングルブラケット Angle bracket 尖括号 プレースホルダ Placeholder 占位符
- 【HDU - 1257】最少拦截系统(贪心)
最少拦截系统 Descriptions: 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的 ...
- 黑客攻防技术宝典web实战篇:Web 应用程序技术习题
猫宁!!! 参考链接:http://www.ituring.com.cn/book/885 随书答案. 1. OPTIONS 方法有什么作用? OPTIONS 方法要求服务器报告可用于特定资源的 HT ...
- RobotFrameWork自动化系列:安装配置
1. RobotFrameWork安装配置 1.1. 安装环境 64位win10家庭中文版 网上很多这方面的教程,但是比较零散,这里是自己安装配置的一个简单的笔记. 1.2. 安装说明 由于Rob ...
- Marriage Ceremonies LightOJ - 1011
Marriage Ceremonies LightOJ - 1011 常规状压dp.popcount(S)表示S集合中元素数量.ans[S]表示S中的女性与前popcount(S)个男性结婚的最大收益 ...
- ACM_LRU页面置换算法
LRU页面置换算法 Time Limit: 2000/1000ms (Java/Others) Problem Description: sss操作系统没听课, 这周的操作系统作业完全不会, 你能帮他 ...
- EJB Timer Service is not available. Timers for application with id 95795415990861824 will not be deleted
delete follows:glassfish\domains\domain1\applications\ejb-timer-service-appglassfish\domains\domain1 ...
- Web API DataContract DataMember Serializable简单解释
首先看一下DataContract这个类契约: Web API/WCF 中类一旦标记了DataContract 属性,那么类中的属性只有被标记为DataMember属性才会被序列化,也就是说一个类的属 ...