Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: can sub check context for lvalue vs rvalue context?

by Anonymous Monk
on May 11, 2018 at 18:36 UTC ( [id://1214394]=note: print w/replies, xml ) Need Help??


in reply to can sub check context for lvalue vs rvalue context?

There does not seem to be a meaningful distinction in Perl. The return value is not intimately connected to the following assignment. Consider this snippet:

use Data::Dump; my $foo = 7; sub bar :lvalue { $foo } sub baz :lvalue { bar } dd $foo, bar(), baz(); baz = 9; for (baz) { dd $foo; $_ = 4; dd $foo; }

As you can see, $foo is passed around (by reference), but there is no telling if and where it is going to be assigned.

Replies are listed 'Best First'.
Re^2: can sub check context for lvalue vs rvalue context?
by LanX (Saint) on May 11, 2018 at 18:43 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-25 05:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found