Beefy Boxes and Bandwidth Generously Provided by pair Networks
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??


in reply to Re^2: if ($2) behaves differently than if (defined $2)
in thread if ($2) behaves differently than if (defined $2)

Apparently, in Lisp, this is referred to as a semi-predicate problem.

The very fact that you are using
if ($2)
followed by
$price = $1 . "." . $2
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://680864]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-24 15:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found