in reply to Re: Re: "my" variables going public?
in thread "my" variables going public?
$foo::bar *is* set in the subroutine in foo.pm. So it's visible everywhere after that subroutine is executed, as $foo::bar.
The $foo=6; in that sub sets the my variable to 6. You get an uninitialized value error at line 7 because you haven't called foo:set_foobar yet, but the next time you try to print out that value (at line 13), you have.
You code, as it stands, *never* sets $foo::foo. And, unless it is the return value of a sub in foo.pm, you'll never be able to see the value of that my variable in any code that lives outside foo.pm
For more goodness on this stuff, check out Dominus' home node and follow the link to "Coping With Scoping".
HTH
|
|---|