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