in reply to each function

What do you mean by "don't work"? say without a parameter prints $_ (and $\), but neither while nor each assign to $_, so you are just getting a bunch of empty lines, one for each key of the hash.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: each function
by RonW (Parson) on Jun 03, 2014 at 23:08 UTC

    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)