Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: my and local variable significance in a particular case

by tobyink (Abbot)
on Apr 24, 2012 at 09:31 UTC ( #966768=note: print w/ replies, xml ) Need Help??


in reply to my and local variable significance in a particular case

$x = "x"; $y = "y"; sub uc_call { my $x = uc $x; local $y = uc $y; shift->(); } my $code = sub { print "$x $y\n" }; uc_call($code);

The above prints lower-case "x" but upper-case "Y", which illustrates that even without strictures, there's a difference between local and my.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


Comment on Re: my and local variable significance in a particular case
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2015-07-31 18:57 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 (280 votes), past polls