Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Extract keys from an Array of Hashes

by BrowserUk (Pope)
on Dec 16, 2010 at 17:07 UTC ( #877525=note: print w/replies, xml ) Need Help??


in reply to Extract keys from an Array of Hashes

print keys %{ $AoH[0] };

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Extract keys from an Array of Hashes
by bradcathey (Prior) on Dec 16, 2010 at 17:17 UTC

    Brilliant!

    I was close, but that doesn't count.

    Stuck them in an array for good measure:

    my @keys = keys %{ $AoH[0] };

    Thanks!

    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
Re^2: Extract keys from an Array of Hashes
by bradcathey (Prior) on Dec 17, 2010 at 03:23 UTC

    And for when the keys are all different:

    for ( 0 .. $#AoH ) { push @keys, keys %{ $AoH[$_] }; }
    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2020-10-20 07:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (209 votes). Check out past polls.

    Notices?