Well for some odd reason I thought I'd add this in. I've actually used it but its been in the back of my mind.
while(($key, $value) = each %Your_hash){ print "$key contains the value: $value !"; }

Replies are listed 'Best First'.
Re: Easier than foreach $key (keys %links) loop
by merlyn (Sage) on Nov 22, 2000 at 03:44 UTC
    The problem is that there's no place to insert a "sort" here. And if you abort the loop early, you run the risk of leaving the secret "each" pointer sitting somewhere in the middle of the hash, confusing the next such loop.

    So, "easier" is all relative. If this floats your boat, use it.

    -- Randal L. Schwartz, Perl hacker