in reply to Re: String equality and undef
in thread String equality and undef
On the other hand, dealing with a bogus value is usually shorter than what you do with a real value, and I think a good style guideline is to keep "else" as close as possible to the condition it negates.
if ( ! defined $id ) { die "Why is this ID not defined?" } else { # Twenty # or # more # lines }
I like this guideline because I've too many times found myself looking at a screen of code like this:
# blah # blah } else { return undef; } } else { unlink $tmpfile; return undef; }
What were the conditions?
Even better in this case would have been an early return so as to avoid the extra level of indent anyway, but that's beside the point.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: String equality and undef
by webfiend (Vicar) on Dec 09, 2008 at 16:36 UTC |