Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
What you're looking for is called a "singleton" - an object which naturally has a single instantiation which is shared by everyone that needs it. This is common for DBI handles for example. You might take a look at Class::Singleton for a tiny bit of implementation help but personally I'd just code the interface myself.
As to whether it's "bad" - no, but it does come with some danger. In the case of DBI handles the fact that they're often shared by disparate modules can make agreeing on DBI options hard - one part needs a particular RootClass, another requires RaiseError to be off, etc. It can cause "action at a distance" problems too. -sam In reply to Re: Are global variables "bad"?
by samtregar
|
|