You could use this
Update: Corrected typo (s/0/$_/)
sub zip { map{ $_[0][$_], $_[1][$_] } 0 .. $#{$_[0]} } my %hash = zip [ 1 .. 3 ], [ 'a' .. 'c' ]; my @a = 1 .. 3; my @b = 'a' .. 'c'; my %hash = zip \@a, \@b;
In reply to Re: Declare and slice-initialize hash in one statement?
by BrowserUk
in thread Declare and slice-initialize hash in one statement?
by chester
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |