in reply to Declare and slice-initialize hash in one statement?
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Declare and slice-initialize hash in one statement?
by xdg (Monsignor) on Oct 27, 2005 at 16:51 UTC | |
by BrowserUk (Patriarch) on Oct 27, 2005 at 17:06 UTC | |
by Roy Johnson (Monsignor) on Oct 27, 2005 at 17:25 UTC | |
by BrowserUk (Patriarch) on Oct 27, 2005 at 17:36 UTC | |
by Roy Johnson (Monsignor) on Oct 27, 2005 at 17:46 UTC | |
| |
|
Re^2: Declare and slice-initialize hash in one statement?
by Juerd (Abbot) on Oct 27, 2005 at 18:56 UTC |