Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Autovivification of scalars in sub calls

by Roy Johnson (Monsignor)
on Dec 08, 2005 at 18:47 UTC ( #515333=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Autovivification of scalars in sub calls
in thread Autovivification of scalars in sub calls

How is the argument in sleep( 3 ) an lvalue?
In much the same way that \3 is. Not a very good answer, I know, but it's the best I can do. Perl makes @_ an array of aliases to the arguments, as you know. That's much like taking a reference: it requires Perl to consider the arguments in an lvalue context. That aliasing may not happen on builtin functions like sleep, though.

Another example of aliasing is a for loop. It also provides an lvalue context:

use warnings; use strict; my $x; # @$x; # This will die if uncommented for my $foo (@$x) { print "Gar!\n"; }
While I'm certain that I read about the @_ lvalues phenomenon here on PM, I haven't been able to Super Search it up. tye mentions it in Re^5: Warnings not being thrown with DBI (nits).

Caution: Contents may have been coded under pressure.


Comment on Re^3: 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://515333]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2014-09-21 15:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (172 votes), past polls