Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
good chemistry is complicated,
and a little bit messy -LW

Re: Perl-ish way to create hash from array

by LanX (Abbot)
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?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (14)
As of 2014-04-25 09:49 GMT
Find Nodes?
    Voting Booth?

    April first is:

    Results (586 votes), past polls