Just another Perl shrine | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
... 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. I feel the risk of that happening is mildly exaggerated. :-) If you directly evaluate the return value of the sub for truth you supply the sub a Boolean context, and there will be no problem. To run into problems, you'd have to call the sub in a list context, save the list of 1 return value and then evaluate that in scalar context. But then the problem would be evaluating a list in scalar context when you didn't mean to. — Arien In reply to Re(2): variable set to 0 ? 0 : 1
by Arien
|
|