in reply to Re: I need a simple explantion of the difference between my() and local()
in thread I need a simple explantion of the difference between my() and local()

Says ctl:
Actually, all he has to do is:
sub A { local $x = 3; &B; } sub B{ $x } my $x = 2; print &A; #prints 3 not 2
That's not the right example either, because you don't need local at all in that case:

sub A { $x = 3; &B; } sub B{ $x } my $x = 2; print &A;
It still prints 3 and not 2. And nobody who understands what my is about could expect it to print 2.

weren't you a bit harsh to the previous poster as they made a simple mistake about where they put a line?
I was harsh, and I apologize. I get very steamed when people post corrections that include broken code, but that's no excuse for being rude.
it's also good to not give the original poster the impression that local() is a bug which should be gotten rid of
Well, here we disagree. I think that's a fine impression to give them. The fraction of correct uses of local by beginning programmers is vanishingly small or zero.

--
Mark Dominus
Perl Paraphernalia