in reply to Re: each function
in thread each function

Elaborating: each returns a key/value pair, so you need to:

while (my ($k,$v) = each %hash)

Though in a scalar context, each returns just the key, but I think keys is more readable:

for (keys %hash)