in reply to Avoiding global object handle
You could also take a look at Class::Singleton. Possibly you could subclass this to be a repository for handles. For instance, (assuming $rep is an instance of a subclass of Class::Singleton) add a handle using $rep->add_handle("Module1", Module1->new() );, then call $rep->get_handle("Module1") to retrieve the handle later. Of course, you'll need to write these methods yourself.
That way, you only need to add use Rep; our $rep = Rep->new(); into the modules that will need to access any of the handles.
It has the same effect of having globals, but just seems to me a bit cleaner, along with less names of globals running around.
|
|---|