in reply to Re^2: Why do I get a "used only once" warning here?
in thread Why do I get a "used only once" warning here?
... the variable would be in a different package ...
... I don't need to put once in its own package; I can simply have it in my current package, and this would make your solution indeed feasible.I'm still a bit confused, and I suspect we may be posting at cross-purposes.
What I wanted to illustrate is that a package variable may be declared in any package at any time (with either use vars or our), and may then be accessed from any other package at any (executionally subsequent) time.
Update: Oops... Forgot to include example code.>perl -wMstrict -le "package Some::Package; our $scalar = 'foo'; package Some::Other::Package; print $Some::Package::scalar; print 'current package is ', eval { scalar caller }; " foo current package is Some::Other::Package
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Why do I get a "used only once" warning here?
by rovf (Priest) on Mar 17, 2009 at 07:52 UTC | |
by AnomalousMonk (Archbishop) on Mar 17, 2009 at 15:53 UTC |