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:
Then you would have seen that only the first element is accessed.while((my $key,my $value) = each %hash) { print "$key - $value\n"; $count++ if $value==keys(%hash); }
After that, you might want to comment out parts uncommon to you, e.g. by
Now you see that the each works fine.while((my $key,my $value) = each %hash) { print "$key - $value\n"; $count++; # if $value==keys(%hash); }
In a third step, google for "perl keys each" - and you'll find the exact reason and link as provided by jwkrahn.
HTH, Rata
|
|---|