in reply to Two arrays into hash
is equivalent to/can be re-written as:@array1=qw(A B C); @array2=qw(1 2 3);
Also, the requirement can be re-written as:@array1=('A', 'B', 'C'); @array2=('1', '2', '3');
So, substituting for ('A','B','C') & ('1','2','3'), into the re-written required result, gives:%hash = ( array1=>[('A','B','C')], array2=>[('1','2','3')] };
But, [@array] can be/usually is written as \@array, hence,%hash = ( array1=>[@array1], array2=>[@array2] };
As required - also discoverable by reference to perlreftut - as moritz has previously suggested.%hash = ( array1=>\@array1, array2=>\@array2 };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Two arrays into hash
by davorg (Chancellor) on Jul 16, 2009 at 10:40 UTC | |
by Bloodnok (Vicar) on Jul 16, 2009 at 10:43 UTC |