in reply to hash and while

jwkrahn was faster than me. Nevertheless some hints:

If you suspect an infinite loop, try to find out what is looping, e.g. with the following code:

while((my $key,my $value) = each %hash) { print "$key - $value\n"; $count++ if $value==keys(%hash); }
Then you would have seen that only the first element is accessed.

After that, you might want to comment out parts uncommon to you, e.g. by

while((my $key,my $value) = each %hash) { print "$key - $value\n"; $count++; # if $value==keys(%hash); }
Now you see that the each works fine.

In a third step, google for "perl keys each" - and you'll find the exact reason and link as provided by jwkrahn.

HTH, Rata