in reply to "my" variables going public?
my variables don't live in a symbol table, and so don't have fully qualified names.
Package variables (aka package globals) do, and do respectively.
so
package foo; my $foo = 'bar';
does not set $foo::foo. The call to set $foo in the subroutine sees only the my variable, because the use of my to declare a $foo masks the package global.
Note also that this 'masking' works even through different packages. my variables are visible within their scope, which can cross package boundaries.
That makes sense, because one always has a way of accessing $foo::foo with a fully qualified name, but you won't have that with my.
does that help?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: "my" variables going public?
by DeaconBlues (Monk) on May 21, 2001 at 23:30 UTC | |
by arturo (Vicar) on May 21, 2001 at 23:54 UTC |