Perl Monk, Perl Meditation | |
PerlMonks |
Re^3: if ($2) behaves differently than if (defined $2)by repellent (Priest) |
on Apr 16, 2008 at 16:57 UTC ( [id://680864]=note: print w/replies, xml ) | Need Help?? |
Apparently, in Lisp, this is referred to as a semi-predicate problem. The very fact that you are using followed by shows that you are using $2 as a semi-predicate, i.e. to show validity and to hold value. Next time, whenever you use if ($var), you should consider if $var needs to be a full-predicate, i.e. strictly a boolean to only show true-or-false.
In Section
Seekers of Perl Wisdom
|
|