in reply to Re^3: Autovivification of scalars in sub calls
in thread Autovivification of scalars in sub calls
Perhaps also interesting is that lvalues remain lvalues even after passing them to the unary + operator.
And testing to make sure:sub foo {} #foo(substr "hello", 10, 1); # fatal error as you pointed out #foo(+substr "hello", 10, 1); # I thought this would be a workaro +und foo(scalar substr "hello", 10, 1); # but you need something like this print "This only gets printed if the last line didn't cause a fatal er +ror\n";
(I know it's documented that + does absolutely nothing, and I guess that does mean it doesn't convert lvalues to rvalues, but it's still somewhat surprising to me.)perl -e '+$a = "Hello, world!\n"; print $a' Hello, world!
|
---|
In Section
Meditations