|
|
| P is for Practical | |
| PerlMonks |
Re^2: Breaking The Rulesby GrandFather (Saint) |
| on May 30, 2006 at 18:32 UTC ( [id://552646]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
I would write:
Why the test? If $var is undef something much more serious is going on and I want to know about it. Yes, I know this is a trivial example and you imply that there may be legitimate situations in which $var is undef. However I'm suggesting that if $var is undef when you are about to print its contents, then there is a flaw in the code. It may be as trivial as not having provided a default value, but providing the default value is important - it says to the reader that you have thought about the special case of the variable contents haven't been changed. BTW, your second version is needlessly convoluted and will generate a warning (two if $var is undefined). KISS DWIM is Perl's answer to Gödel
In Section
Meditations
|
|
||||||||||||||||||||||||||||||||||||||||||||||