in reply to trouble with each and a hash of hashes
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: trouble with each and a hash of hashes
by marcokuma (Novice) on Sep 11, 2004 at 13:48 UTC | |
by jdalbec (Deacon) on Sep 11, 2004 at 14:42 UTC | |
by marcokuma (Novice) on Sep 11, 2004 at 16:13 UTC | |
by shenme (Priest) on Sep 11, 2004 at 18:57 UTC | |
by CountZero (Bishop) on Sep 11, 2004 at 13:56 UTC |