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的操作 ...
随机推荐
- django-ckeditor表情包修改
一.版本 Django==1.11 django-ckeditor==5.2.2 二.关键步骤 1.删除旧的ckeditor静态文件 所在目录:项目目录下的static文件夹下的ckditor文件夹 ...
- 洛谷 - P1115 - 最大子段和 - 简单dp
https://www.luogu.org/problemnew/show/P1115 简单到不想说……dp[i]表示以i为结尾的最大连续和的值. 那么答案肯定就是最大值了.求一次max就可以了. 仔 ...
- Codeforces703B Mishka and trip
题意: 就是有n个点,本来相邻点之间就有一条边,1和n之间也有一条,然后给你几个特殊点,说这些特殊点和其他所有点都连起来了,然后算一个所有边的权值和,每条边的权值等于两个点的c相乘. 思路: 水题啊- ...
- hdoj1394
题意还告诉我们是0-n-1之间的数,那么我们每次把一个数放到后面去,求一下比他大的,还有比他小的: 比如: 1 3 6 9 0 8 5 7 4 2 逆序数num:22 3 6 9 0 8 5 7 4 ...
- bzoj 4199: [Noi2015]品酒大会【后缀数组+单调栈+并查集】
用SA求出height数组,然后发现每个height值都有一个贡献区间(因为点对之间要依次取min) 用单调栈处理出区间,第一问就做完了 然后用并查集维护每个点的贡献(?),从大到小枚举height, ...
- Codeforces 1000 (A~E)
A Codehorses T-shirts 相同长度之间互相转化即可 #include<iostream> #include<cstdio> #include<cstri ...
- 如果没有intelliJ 编译器?
刚刚是了一晚上的用记事本来写代码,脱离编译器,发现自己完全废了. 写了好多个类,在命令行编译失败,上网查错误,说编码问题, 编码问题解决后,命令行还是编译失败,粘贴到编译器 发现完全是自己代码能力太弱 ...
- Hexo搭建博客教程(3) - 远程部署到GitHub Pages
本章讲的是如何将本地的个人项目远程部署到 GitHub Pages,涉及到GitHub的项目仓库.Git的使用,以及Hexo的远程部署等. 1. 安装 hexo-deployer-git 插件 想要将 ...
- ultraedit 窗口布局
回复默认的设置:工具栏中的视图-->环境-->左边小框里选择“编程员”,再点选择环境 改变使UltraEdit有多个窗口出来 视图’——‘视图/列表’——‘打开文件标签
- Oracle 正则化
摘抄自:http://www.cnblogs.com/scottckt/archive/2012/10/11/2719562.html ORACLE中的支持正则表达式的函数主要有下面四个: 1,REG ...