The while will fall through when the assignment($s_pattern,$p_pattern) = each %{$patterns{$gen}} is false. This should normally only happen when you reach the "end" of your HOH.
foreach on the other hand will dutyfully churn through the whole of the array (keys returns an array of key-values) even if they are empty, undef or NULL. Strange as it may seem, but they the key-value of a hash can be empty and the value-value can be undef. Did you have a look at your data-structures with Data::Dumper? Always a great help to do!
Update: fixed a typo.
CountZero
"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
In reply to Re: trouble with each and a hash of hashes
by CountZero
in thread trouble with each and a hash of hashes
by marcokuma
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |