Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: In What basis the subroutine return values assign to variables ?

by FunkyMonk (Chancellor)
on Jul 30, 2007 at 10:38 UTC ( [id://629521]=note: print w/replies, xml ) Need Help??


in reply to In What basis the subroutine return values assign to variables ?

|| is causing get_price_floor() to be evaluated in scalar context. A list eg (10, 8), when evaluated in scalar context, returns the last element, 8. That's what's assigned to $price, while $floor is left undefined.

Simple solution: get rid of || 0

BTW, do you know what & does to a subroutine call? If you don't (and I don't believe you do), don't use it. Just call your subroutine without it:

my ($price, $floor) = get_price_floor();

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-24 18:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found