Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Play golf on an array of hashrefs

by frankus (Priest)
on Jun 10, 2002 at 15:38 UTC ( #173199=note: print w/replies, xml ) Need Help??

in reply to Play golf on an array of hashrefs

my @myvalues = map {$$elem{mykey} } @array;


Brother Frankus.


Replies are listed 'Best First'.
Re: Re: Play golf on an array of hashrefs
by mephit (Scribe) on Jun 10, 2002 at 21:37 UTC
    Actually, the use of $elem in the map won't work, as the OP used $elem as the "alias" variable in the foreach loop. There is no alias in this map.
    $> perl -e '@array=({mykey=>foo}, {mykey=>bar}), @out = map{ $$elem{my +key} } @array; print @out;' $>
    Use $_ instead, as Joost or Abigail suggested.


    There are 10 kinds of people -- those that understand binary, and those that don't.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2018-06-22 02:07 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (120 votes). Check out past polls.