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

Re^13: If you believe in Lists in Scalar Context, Clap your Hands

by ysth (Canon)
on Oct 28, 2008 at 06:25 UTC ( [id://719916]=note: print w/replies, xml ) Need Help??


in reply to Re^12: If you believe in Lists in Scalar Context, Clap your Hands
in thread If you believe in Lists in Scalar Context, Clap your Hands

The assignment operator itself happens to be both in scalar and in list context. It produces both a list for the list, and a scalar for the function scalar().
No. The assignment operator does the assignment, but it doesn't produce a list. The assignment is the side-effect; the result is a scalar due to the scalar context. Similar to how the ++ in perl -we'print $i++' produces 0 while incrementing $x.

Replies are listed 'Best First'.
Re^14: If you believe in Lists in Scalar Context, Clap your Hands
by mr_mischief (Monsignor) on Oct 28, 2008 at 14:02 UTC
    You are confused what I'm talking about. I'm not talking about how it happens in the interpreter. I'm talking about what appears to happen, so that people understand what the folks who talk about lists in scalar context are seeing from their POV. Look at the notation and pretend you know nothing about how perl works, and are only beginning with Perl.
      No, I'm not confused. Operators do something and return something. This is both what happens and what appears to happen. The assignment operator gets the list on the right, it doesn't in any way produce or return it.
        Who cares about the list on the right. What appears to happen to the list on the left? It appears to be yielded by the assignment. In fact, it is, but as a side effect.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-23 17:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found