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.
In reply to Re: Perl-ish way to create hash from array
by rjt
in thread Perl-ish way to create hash from array
by gri6507
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |