Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: difference between delete and undefby manoj_speed (Prior) |
on Mar 18, 2009 at 04:11 UTC ( [id://751349]=note: print w/replies, xml ) | Need Help?? |
Hashes contain pairs of scalars: the first is the key, the second is the value. The key will be coerced to a string, although the value can be any kind of scalar: string, number, or reference. If a key $key is present in %hash, "exists($hash{$key})" will return true. The value for a given key can be "undef", in which case $hash{$key} will be "undef" while "exists $hash{$key}" will return true. This corresponds to ($key, "undef") being in the hash. Pictures help... here's the %hash table: keys values
In Section
Seekers of Perl Wisdom
|
|