Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Perl-ish way to create hash from array

by rjt (Deacon)
on Jul 09, 2013 at 20:42 UTC ( #1043373=note: print w/replies, xml ) Need Help??


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

As of Perl 5.12, each works on arrays:

use 5.012; use warnings; my @array = qw/zero one two three four five six/; my %hash; while (my ($idx, $val) = each @array) { $hash{$idx} = $val };

I wouldn't call this a "win" in this particular example over using a slice or Text::CSV's own API, but it's not bad, and in more complex situations it works handily.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043373]
help
Chatterbox?
[Corion]: Hi marto!
[Corion]: I just found out that in $current_top_prior ity_project , the part I am in is not even in the top three worries. That's somewhat bad, not because I'm happy with being a top worry but because that means that I don't even know how bad the rest ...
[Corion]: ... of the situation is :-)

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2017-07-26 08:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (385 votes). Check out past polls.