It certainly is. For instance, the first element in your array is $array[0]; since this is a hash reference, you can deference it and turn it into a proper hash again by saying %{ $array[0] } (the whitespace isn't necessary; it just improves readability). And since that's just a hash, you can access its elements as usual, e.g. ${ $array[0] }{'somekey'}.
That last bit of syntax is clunky, of course, so Perl provides the -> postfix operator for dereferencing and element access as well; using that, you can also write $array[0]->{'somekey'}, which is much more readable and makes it more obvious what's going on.
Example:
#!/usr/bin/perl use feature qw/say/; use warnings; use strict; my @array = ( { 'Fred' => 'Flintstone', 'Barney' => 'Rubble' } ); say $array[0]; say %{ $array[0] }; say ${ $array[0] }{'Fred'}; say $array[0]->{'Fred'}; $array[0]->{'Betty'} = 'Rubble'; say $array[0]->{'Betty'};
Output:
$ perl test.pl HASH(0x8002bc80) BarneyRubbleFredFlintstone Flintstone Flintstone Rubble $
EDIT: removed superfluous use Data::Dumper; -- good catch, hexcoder. :)
In reply to Re: Updating hash using it's reference ...
by AppleFritter
in thread Updating hash using it's reference ...
by karthikin2asic
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |