Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2016-09-28 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (526 votes). Check out past polls.