RosettaCodeData/Task/Pointers-and-references/Perl/pointers-and-references-2.pl

11 lines
362 B
Perl
Raw Permalink Normal View History

2015-02-20 00:35:01 -05:00
# accessing the value
print $$scalarref; # 'aa'
print @$arrayref; # 'bbcc'
print $arrayref->[1]; # 'cc'
print $hashref->{ee}; # 'EE'
2013-04-10 23:57:08 -07:00
# changing the value
2015-02-20 00:35:01 -05:00
$$scalarref = 'a new string'; # changes $scalar
$arrayref->[0] = 'foo'; # changes the first value of @array
$hashref->{'dd'} = 'bar'; # changes the value with key 'dd' in %hash