Per script hangs at ~7200 interactions of a hash of hash

Viewed 50

I have a hash of hash with a total of 10000 iterations max, but it always hangs at the 7219 iteration count. It doesn't seem to be because of memory because I commented/uncommented the rest of the code in several turns and it always hangs at a certain number. It works perfectly fine every time if the hash of hash size is small and iteration less than 7k.

for my $var1 (keys %hash_of_hash ) 
{
   for my $var2 (keys %{ $hash_of_hash {$var1}{fields} }) 
   {
       print "\nDelete this comment of hash";       
       print "count- $counter Register- $var1 Field $var2";      
       $counter++;      
       #code -commented/uncommented   
   }
}

1 Answers

I don't think it's hanging in the loop at all. I think you are successfully iterating over the entire hash, but that you haven't received the entire output because of buffering.

Add $| = 1; to disable buffering on the default handle (STDOUT).

Alternatively, since STDERR isn't buffered by default, warn is a better for temporary debug statements than print/say.

Related