No, it doesn't do that. Too bad you didn't try it!my $x = 2; sub A { local $x = 3; &B; } sub B{ $x } print &A; #prints 3 not 2
"Always use my, never use local" is advice for people who don't understand the complexities yet. It's like the rule your mom told you about not talking to strangers. Is it always wrong to talk to strangers? No, of course not. Can a little kid be trusted to know when the rule doesn't apply? No.
So until Jemts can read those tutorials and understand what they mean, he's better off following the rule. You might be better off also---it would at least stop you from saying silly things on Perlmonks.
--
Mark Dominus
Perl Paraphernalia
In reply to Re: I need a simple explantion of the difference between my() and local()
by Dominus
in thread I need a simple explantion of the difference between my() and local()
by Jemts
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |