[英]perl hash ref operator is working weirdly
I m having a single array ref consisting a list of hash refs. 我有一个包含散列引用列表的数组引用。
Here is the code: 这是代码:
use strict;
use warnings;
my $arrayRef = [
{
'URL' => 'http://example.com/1.jpg',
'ORD' => '1',
},
{
'URL' => 'http://example.com/2.jpg',
'ORD' => '2',
},
{
'URL' => 'http://example.com/3.jpg',
'ORD' => '3',
},
];
print $arrayRef->[0]->{URL},"\n"; # http://example.com/1.jpg
print $arrayRef->[0]{URL},"\n"; # http://example.com/1.jpg
Since it is an hash ref i am using ->
operator to get a value, but im getting the same value without using the ->
operator is it fine? 因为它是一个哈希引用,我使用
->
运算符来获取一个值,但我得到相同的值而不使用->
运算符是没关系的吗?
It's valid, a kind of syntactic sugar, and it refers to the same item. 它是有效的,一种语法糖,它指的是同一个项目。 The Perl references tutorial writes about this
Perl参考教程写到了这一点
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.