Another way would be just to call ::main::debug->method(args) from inside your $cust object, but this would be making the Customer object dependent upon the main having such an object, and saving it under this name. (if you later decided to change the instance of the Debug object to be called $mydebug, you'd have to change Customer as well.)
A third slightly similar way would be to have Customer call a function in main, which returns it the debug object, whenever it needs it. (In Customer) my $debugobj = ::main::getDebugObj();, but this is again dependent upon main implementing this method.. (Ok, its your main, but what if someone else used your classes?).
Fourth: (While I think of it) - Have a common Id in Customer and Debug, and keep references to the Debug objects in the Debug class. Now Customer can ask Debug directly for a specific Debug object. (it's still kinda backwards though :). my $debugobj = Debug::getDebugObj($me->debugID); (or something..)
Lastly, something like debugging can usually be done with a Singleton, ie one single object that handles debugging, instead of instanciating lots of debug objects. (Tho I guess your question was more general than that..)
C.
In reply to Re: Accessing an instantiated object from another .pm file
by castaway
in thread Accessing an instantiated object from another .pm file
by arc_of_descent
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |