Re: access values in array of hashrefs

[email protected] (Gunnar Hjalmarsson)
Newsgroups perl.beginners
Message-ID <[email protected]>
Ryan wrote:
> my $HHs=[
>     {Rx => 'test', key2 => '1st second key' },
>     {Rx => '2nd1', key2 => '2nd second key' },
>     {Rx => '3rd1', key2 => '3rd second key' }
> ];
> 
> say join(', ', @{$HHs->{Rx}}); # say all the values of the 'Rx' key in 
> each element of @$HHs.
> 
> Is there an easy way to do what I want here?

     say join ', ', map $_->{Rx}, @$HHs;

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.