Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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 rifling through the Monastery: (6)
As of 2014-08-29 02:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls