in reply to String equality and undef
If you follow the very good advice of using defined as the test, you might also want to switch the ordering of your if/else logic. Instead of
if (!defined $id) { # Deal with id } else { # Deal with not undef id }
you might want to consider
if (defined $id) { # Deal with a defined id } else { # Deal with an undefined id }
It's just personal aesthetics. The first form ("if not" / "else") sounds awkward to me compared to "if" / "else".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: String equality and undef
by kyle (Abbot) on Dec 09, 2008 at 15:42 UTC | |
by webfiend (Vicar) on Dec 09, 2008 at 16:36 UTC |