Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Why does foo() evaluate in array context in "${\foo()}"?

by JavaFan (Canon)
on Apr 23, 2009 at 08:42 UTC ( [id://759484]=note: print w/replies, xml ) Need Help??


in reply to Why does foo() evaluate in array context in "${\foo()}"?

I would have expected that the $ sigil would have biased "${...}" towards a scalar context since the obvious value inside of {...} would naturally be a scalar reference.
You are correct in the sense that ${EXPR} provides scalar context to EXPR.
Thus the thing that "\" takes a reference from should be presumed to be a scalar.
But you are wrong here. You are assuming that \ propagates context. It doesn't. Only a few operators do, and \ isn't one of them. \ always provides list context to its arguments. Regardless of its own context. This is standard behaviour in Perl.

Log In?
Username:
Password:

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

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

    No recent polls found