in reply to hash surprise
Interesting. To quote the good Camel on exists:
The function returns true if the specified hash key or array index exists in its hash or array. It doesn't matter whether the corresponding value is true or false, or whether the value is even defined.
Although the last element will not spring into existence just because its existence was tested, intervening ones will. Thus $$hash{"A"} and $hash{"A"}->{"B"} will both spring into existence. This is not a function of exists, per se; it happens anywhere the arrow operator is used (explicitly or implicitly).if (exists %hash{A}{B}{$key}) { ... }
Also, you want to wrap your code in <code>...</code> tags. That'll work fine.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
possible fix for: hash surprise
by smackdab (Pilgrim) on Jul 04, 2002 at 06:28 UTC |