use warnings; use strict; my %hash = (4 => 12, 34 => 102); while (my ($k, $v) = each %hash){ print "$k => $v\n"; }
In other words, each() returns two scalar items. What's happening in your case, is that @k is taking both items being returned for each hash key/value pair on each iteration, so there's nothing ever in the @v array. Use scalars like I have instead.
In reply to Re: Output of hash
by stevieb
in thread Output of hash
by catfish1116
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |