Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Re: variable set to 0 ? 0 : 1by hossman (Prior) |
on Sep 06, 2002 at 07:51 UTC ( [id://195592]=note: print w/replies, xml ) | Need Help?? |
Returning zero in Perl is usually a bad meme. It is ok if you actually meant to return a numeric zero, but if you mean to return "false", the Perlish way is to return an empty list. This is because by returning 0 you return a single-element list, which evaluates to true in list context. The code would then look like this: The opposite could be argued just as easily: if you return an empty list to mean "false", the false-ish-ness could be lost (or other problems could arise) if your return value is "slurped" into another list context. Consider...
Bottom line: there's no substite for Update: good point blakem
In Section
Seekers of Perl Wisdom
|
|