Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Determining subroutine return type

by sandfly (Beadle)
on Feb 24, 2005 at 23:16 UTC ( [id://434298]=note: print w/replies, xml ) Need Help??


in reply to Re: Determining subroutine return type
in thread Determining subroutine return type

Subs returning arrays behave differently to subs returning lists. If your sub returns an array, calling it in scalar context gets you the number of elements. In list context there's no difference.
perl -le "@a=(2,4,6); sub x{@a} print scalar(x());"
prints 3, not 6.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://434298]
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: (8)
As of 2024-04-25 10:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found