From: "Kirk" <[EMAIL PROTECTED]>

> Not exactly.  There are several dozen parent programs that call a
> single child program (a global DBI handle).  I've just discovered that
> many of the calling parent programs are using "require".  So what I
> have is:
> 
> #!/usr/local/bin/perl
> # filename: parent.pl
> require child.pl
> ...
> ...
> 
> And in child.pl, I need to determine the name of the parent program
> which called it.  A simple $0 wont due and "caller" doesn't apply. 
> Any other suggestions?

Could you try to tell us
        1) What is a process?
        2) What is a program?
        3) What is a library?

Do you have a process that is running "in the background" serving 
as a "global DBH handle" and several other processes that connect 
to that process using pipes or shared memory or something else?
I doubt it. And I do not see any reason why would you want to do 
that.

I am sure (99.9%) you merely have a LIBRARY (child.pl) that's is 
required IN several programs. The code in child.pl then runs INSIDE 
the process that gets created when you start any of the programs 
and if it looks at $0 it'll see the name of the MAIN file of the 
program.

Eg. if you have

        #child.pl
        print "Program name/path: $0\n";
        1;

        #parent1.pl
        require "child.pl";
        print "END process 1\n";

        #parent2.pl
        require "child.pl";
        print "END process 2\n";

and run

        > perl parent1.pl
you'll get
        Program name/path: parent1.pl
        END process 1
and for
        > perl parent2.pl
        Program name/path: parent2.pl
        END process 2

The child.pl would only ever print 
        Program name/path: child.pl
if you run it directly, NEVER if you only "require" it.
        > perl child.pl
        


So back to what you wrote:

# filename: parent.pl
> require child.pl
> ...
> ...
> 
> And in child.pl, I need to determine the name of the parent
> program which called it. 

child.pl is NOT a program, and it was NOT called. require() doesn't 
"call" programs, it includes libraries.

Jenda


=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain
I can't find it.
                                        --- me
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to