How can I create a package that allows me to use scalars within that package that are Global to the package, but Encapsulated from the rest of the cruel mean world?
Have a look at inside out objects. Modules Class::Std or Object::InsideOut make them easy. This might give you the idea:
package SafeHaven; { my $glow_ball; sub get_glow_ball { return $glow_ball; } sub set_glow_ball { my $self = shift; $glow_ball = shift; } }
The lexically scoped $glow_ball is available to every sub inside its scope. The rest of your code can stay the same (but also go in the lexical scope) and still work, but you can also change it to get other advantages of inside-out objects.
In reply to Re: Something I'd really like to know about OOP Perl.
by kyle
in thread Something I'd really like to know about OOP Perl.
by Sagacity
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |