Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

(tye)Re: @_0 vs. $_0

by tye (Cardinal)
on Nov 22, 2000 at 20:32 UTC ( #42955=note: print w/ replies, xml ) Need Help??


in reply to @_0 vs. $_0

Forcing a list into scalar context returns its last argument,

Um, no. Make that NO. (:

Constructs that would return a list of scalars if used in a list context may or may not return the last scalar of that list if used in a scalar context.

I choose that wording very carefully as the word "list" is not narrowly defined for Perl and can mean any number of things (despite the fact that "scalar", "scalar context", and "list context" are all clearly defined for Perl).

Many constructs do behave this way (one reason for the persistent nature of this myth). In particular, an array slice behaves precisely this way. So, if you actually did have a scalar context here, then your conclusion would be correct even though your reasoning was flawed.

        - tye (but my friends call me "Tye")


Comment on (tye)Re: @_0 vs. $_0

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2014-09-19 17:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (144 votes), past polls