A common way to do a "global variable" is to use a Singleon. I would recommend using Class::Singleton vs. rolling your own, but the basic idea is:
No matter how many times Dragonchild::Singleton->new is called, the exact same variable is returned. It's partially a style issue, but I prefer singletons over our'ed variables. Other monks will tell you the opposite. TMTOWDIpackage Dragonchild::Singleton; my $singleton; sub new { my $class = shift; $singleton ||= bless {}, $class; return $singleton; }
------
We are the carpenters and bricklayers of the Information Age.
The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
In reply to Re3: Style and Coding Criticism (part 2)
by dragonchild
in thread Style and Coding Criticism (part 2)
by inelukii
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |