in reply to How to make a hash out of two arrays,one with keys and other with values?
Ok, assuming that the arrays will be mapped element for element without mixing and matching, you can do something like this:
Hope this helped. Regards, Jeffuse strict; use warnings; my @array1 = ('A','B','C','D'); my @array2 = ('1','2','3','4'); my %hash1; foreach my $key (@array1){ $hash1{$key} = shift(@array2); } for my $keys ( sort(keys %hash1 )) { my $value = $hash1{$keys}; print "$keys => $value\n"; }
"Every time Linux boots, a penguin gets its wings"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
How do I delete the first value from this hash?Kindly help!!
by sun@icgeb (Initiate) on Jun 30, 2009 at 11:41 UTC |