Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: array of hashes

by jandrew (Hermit)
on Dec 10, 2010 at 02:42 UTC ( #876364=note: print w/ replies, xml ) Need Help??


in reply to array of hashes

Both more and less.

use 5.010; use strict; use warnings; my @array = ( { car => "ford", color => "red", pet => "dog", }, { car => "honda", color => "blue", pet => "cat", }, { car => "dodge", color => "orange", pet => "spider", }, ); say return_selected_elements( \@array, 'car', 0, 1 ); sub return_selected_elements { my $AoHref = shift; my $element = shift; my @Instances = @_; return join ", ", (map $AoHref->[$_]->{$element}, @Instances); }

Returns

ford, honda


Comment on Re: array of hashes
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://876364]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (14)
As of 2014-10-21 12:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (103 votes), past polls