Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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?

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 having an uproarious good time at the Monastery: (10)
As of 2014-09-22 20:22 GMT
Find Nodes?
    Voting Booth?

    How do you remember the number of days in each month?

    Results (200 votes), past polls