in reply to Output of hash

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.