Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Perl-ish way to create hash from array

by LanX (Canon)
on Jul 09, 2013 at 17:29 UTC ( #1043359=note: print w/ replies, xml ) Need Help??


in reply to Perl-ish way to create hash from array

maybe hash-slices are what you want:

DB<101> @columns=qw(firstname middlename lastname) => ("firstname", "middlename", "lastname") DB<102> @colidx{@columns}=0..$#columns => (0, 1, 2) DB<103> $colidx{middlename} => 1 DB<104> \%colidx => { firstname => 0, lastname => 2, middlename => 1 }

Cheers Rolf

( addicted to the Perl Programming Language)


Comment on Re: Perl-ish way to create hash from array
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (13)
As of 2014-08-27 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (252 votes), past polls