Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: array of hashes

by jandrew (Chaplain)
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://876364]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2016-12-09 04:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (148 votes). Check out past polls.