Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Using map to split an array to hash key/values

by jsegal (Friar)
on Dec 18, 2001 at 02:44 UTC ( [id://132706]=note: print w/replies, xml ) Need Help??


in reply to Using map to split an array to hash key/values

how about
my @array = qw(key1:value1 key2:value2 key3:value3); my %hash = map {split ":"} @array; # .. etc ..
Map evaluates in array context, and if the block in the map clause returns an array (like split does), the elements will be interpolated. This then gets interpreted as a hash. Best of luck.... -Jonathan

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-23 17:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found