Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Perl-ish way to create hash from array

by LanX (Chancellor)
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 taking refuge in the Monastery: (5)
As of 2015-11-28 15:30 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (743 votes), past polls