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的操作 ...
随机推荐
- 【197】PowerShell 通过 FTP 下载文件
参考:使用 WGET 从FTP上下载文件 在 PowerShell 使用 wget2 工具,代码如下: wget2 ftp://user:password@192.168.14.31/1.jpg 其中 ...
- ccflow_005.请假流程-傻瓜表单-审核组件模式
ccflow_005.请假流程-傻瓜表单-审核组件模式 ' 用审核组件演示各个流程应用 首先设置节点,填写请假单的 表单方案.选择内置傻瓜表单.我们之前创建的表单就回来了. 可以点击下面的设计傻瓜表单 ...
- linux下svn的建库以及相关配置
1.安装svn软件 yum install subversion -y 2.建立库的根目录,此目录下为所有库的根目录(路径为:/home/svn-server/) ,然后进入此目录 mkdir /ho ...
- linux C之access函数(转载)
转自:http://blog.sina.com.cn/s/blog_6a1837e90100uh5d.html access():判断是否具有存取文件的权限 相关函数 stat,open,chm ...
- Thirft 客户端等待时间
thrift框架使用C++ thrift shows CLOSE_WAIL error thrift中TNonblockingServer的简单用法
- CodeForces 615C
题意: 给定两个字符串s1,s2利用s1去构造s2,s1有无限个,可以翻转,你最少要用几个s1才能构造s2.输出每一次使用的s1的有效区间. 伪思路: 据说是暴力就能过的题目.然而自己就是暴力差,模拟 ...
- Redis生成主键ID
使用Redis來生成主鍵ID策略,這裡主要使用 RedisAtomicLong 類來實現主鍵生成策略.具體代碼如下: /** * @Description: 获取自增长值 * @param key k ...
- Codeforces 1107E(区间dp)
用solve(l, r, prefix)代表区间l开始r结束.带了prefix个前缀str[l](即l前面的串化简完压缩成prefix-1个str[l],加上str[l]共有prefix个)的最大值. ...
- Codeforces Round #402 (Div. 2) B
Description Polycarp is crazy about round numbers. He especially likes the numbers divisible by 10k. ...
- Common Divisors CodeForces - 182D || kmp最小循环节
Common Divisors CodeForces - 182D 思路:用kmp求next数组的方法求出两个字符串的最小循环节长度(http://blog.csdn.net/acraz/articl ...