in reply to How to create hash out of an array elements?
@arr=(1,2,3,4,5,6,7,8,9,10); %hsh= (); $i=0; while($i<10) { $hsh{$arr[$i]}=$arr[$i+1]; $i=$i+2; } while ( my ($key, $value) = each(%hsh) ) { print "$key => $value\n"; }
output
1 => 2 3 => 4 7 => 8 9 => 10 5 => 6
|
---|
In Section
Seekers of Perl Wisdom