in reply to Hashing it out: defined? exists?
Three ways of checking the value in a hash:
if (exists $hash{$key}) # If exists if (defined $hash{$key}) # If exists, defined if ( $hash{$key}) # If exists, defined and true
If the value is just a flag, then I wouldn't even use defined. I would just treat the value as boolean. It's less verbose, and it works for all three checks listed above.
As for defined vs exists, there isn't really any difference as long as the value can't normally be undefined.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hashing it out: defined? exists?
by pg (Canon) on Sep 02, 2005 at 20:08 UTC | |
|
Re^2: Hashing it out: defined? exists?
by eff_i_g (Curate) on Sep 02, 2005 at 20:08 UTC | |
by ikegami (Patriarch) on Sep 02, 2005 at 20:15 UTC | |
by eff_i_g (Curate) on Sep 02, 2005 at 20:27 UTC | |
by eff_i_g (Curate) on Sep 02, 2005 at 20:10 UTC | |
|
Re^2: Hashing it out: defined? exists?
by Nkuvu (Priest) on Sep 02, 2005 at 19:57 UTC | |
by ikegami (Patriarch) on Sep 02, 2005 at 19:59 UTC | |
by Nkuvu (Priest) on Sep 02, 2005 at 20:19 UTC | |
by ikegami (Patriarch) on Sep 02, 2005 at 20:25 UTC |