加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Perl中@array – > [4]或%hash – > {key}行为的文档在哪

发布时间:2020-12-16 06:20:20 所属栏目:大数据 来源:网络整理
导读:最近的一个问题使用了sigil不变语法%hash- {key} = 1;对于散列访问,这似乎工作正常,但我认为这将是一个语法错误. 它似乎也适用于数组: my @array;@array-[3] = 6; 这种行为是否记录在某处?我不记得读它,但可能忽略了它. 它似乎表现得如下: (%hash)-{key
最近的一个问题使用了sigil不变语法%hash-> {key} = 1;对于散列访问,这似乎工作正常,但我认为这将是一个语法错误.

它似乎也适用于数组:

my @array;

@array->[3] = 6;

这种行为是否记录在某处?我不记得读它,但可能忽略了它.

它似乎表现得如下:

(%hash)->{key}

而不是我会假设的:

(scalar %hash)->{key}  # runtime error

解决方法

似乎这在perlmonks: http://www.perlmonks.org/?node_id=171177中有所涉及

My reading of perlop has me convinced that this is an unintended
syntactic feature.

And that's exactly what it is. When using the arrow,Perl will see
whatever is left of it as a reference. Including if you have something
like @l or %h.

Note that you will get the warning
Using an array as a reference is deprecated in Perl 5.8.0.

  Abigail

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读