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

Re: pushing hash values to an array

by jwkrahn (Abbot)
on Oct 16, 2006 at 15:22 UTC ( [id://578537]=note: print w/replies, xml ) Need Help??


in reply to pushing hash values to an array

foreach $key(keys %h) { push(@arr,$h{$key}); }
Could more simply be written as:
push @arr, values %h;
If the values contain array references then:
push @arr, map @$_, values %h;
Or if the values contain hash references then:
push @arr, map %$_, values %h;
And if you don't know beforehand:
push @arr, map ref() eq 'ARRAY' ? @$_ : ref() eq 'HASH' ? %$_ : $_, va +lues %h;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-19 19:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found