Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^4: Autovivification of scalars in sub calls

by truedfx (Monk)
on Dec 09, 2005 at 11:51 UTC ( #515515=note: print w/ replies, xml ) Need Help??


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.

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";
And testing to make sure:
perl -e '+$a = "Hello, world!\n"; print $a' Hello, world!
(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.)


Comment on Re^4: Autovivification of scalars in sub calls
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2015-07-31 09:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls