Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: regexp list return 5.6 vs 5.8

by ikegami (Patriarch)
on Jan 24, 2008 at 18:29 UTC ( [id://664110]=note: print w/replies, xml ) Need Help??


in reply to Re^2: regexp list return 5.6 vs 5.8
in thread regexp list return 5.6 vs 5.8

Subroutines return a list of scalars, but when the sub is in scalar context, that list will always have exactly one scalar in it.

"A 'return' statement [...] will be evaluated in the appropriate context" means the op which returns the arguments to return is executed in the same context as the sub. It's the *statement* that is evaluated in the appropriate context, not the values returned.

When evaluated in scalar context, arrays return their length. (Case 1)
When evaluated in scalar context, lists return their last element. (Case 3)
When evaluated in scalar context, list assignments return the number of elements assigned. (Case 2 and 4)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-23 18:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found