Hal Vaughan <> wrote:
> I have a module, TD::Log.pm (TD is the company name, so most modules
> are in that directory). When I write a program, I use:
>
> use TD::Log;
>
> as expected. I also have other modules I use. I know a module can
> reference the function "entry()" in the instance TD::Log in the main
> program by using:
>
> main::TD::Log::entry("status: adding today's data to file");
>
> However, what I'd like to do, when I open a new module from main, say
> "TD::IncomingData.pm" is to use main::TD::Log::entry more simply. Is
> there some way, from the main program, I can pass a reference to the
> instance of TD:Log the main program uses to TD::IncomingData so I can
> reference the routines directly in TD::IncomingData? Something like:
>
> use TD::Log;
> use TD::IncomingData;
>
> incomingdatainit({some reference to TD::Log});
my $incoming = new TD::IncomingData;
$incoming->init();
:
> And then, from then on, I can reference the routines in main::TD::Log
> as I would "normally" reference routines in the IncomingData module?
> (Like with "entry()" instead of "main::TD::Log::entry()"?)
Read on Perl OO. There is an excellent book on it, or perldoc perltoot
(for example)
--
John Small Perl scripts:
http://johnbokma.com/perl/
Perl programmer available:
http://castleamber.com/
Happy Customers:
http://castleamber.com/testimonials.html