in reply to Re^5: Pointers and References
in thread Pointers and References
> our tells you something is "global" where you declare the variable, but it doesn't tell you that where you use it.
I have problems to follow. our $var creates a lexically scoped alias to a package variable $PKG::var whith PKG for the current __PACKAGE__ . If you are afraid to loose count "where you use it" just limit the scope, much the same way you do with private vars declared with my.
> of a g prefix is an immediate and obvious reminder at the point of use that this is a global variable.
Then maybe consider full qualification instead of a g_ prefix.
Using $PKG::var is IMHO much clearer, and $::var is a handy shortcut for $main::var
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Pointers and References
by GrandFather (Saint) on Nov 23, 2020 at 22:29 UTC |