in reply to Re: difference between my and local
in thread difference between my and local

I'm not quite sure what you're getting at, but you can certainly get the global value from anywhere, without using local. Observe:
# main scope $fred = 1; #global { # outer scope my $fred = 2; #... { #inner scope print $main::fred; # prints the global 1 } }
The best rule of thumb is to use my unless you have some particular reason to use something else.

Replies are listed 'Best First'.
Re^3: difference between my and local
by Moron (Curate) on Nov 15, 2005 at 14:26 UTC
    You'll find that my is used more often than local. So what I am getting at is that whereas my $fred = $fred will have the same effect as local $fred most of the time, it won't always. I expect the OP to wonder why he ever needs local instead of just using my $fred = $fred rather than to wonder why he needs my - he already knows why he needs my and he already knows broadly what both of these do.

    -M

    Free your mind