In the first version you are manipulating $_, but you
haven't set $_ to any value. you seem to thing that it
will be set to each of your hash keys in turn, there's
no code to make tha happen.
In the second version, you're manipulating the first
element of @_, which _is_ set to each key in turn.
Therefore it works!
hth,
davorg...