Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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 examining the Monastery: (2)
As of 2025-12-10 23:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (91 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.