Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

find out the way program was called.

by coldhawk (Monk)
on Apr 09, 2004 at 00:39 UTC ( #343808=perlquestion: print w/ replies, xml ) Need Help??
coldhawk has asked for the wisdom of the Perl Monks concerning the following question:

I was just thinking, what would be the best way to regonize how is the program being called. What i real mean is, that im trying to find out if it's exec directly or is another perl program using it with require, and do actions based on that. I couldn't find any portable solutions to this, maybe i was searching with wrong search words, but anyway. i would appreciate of any help you may give.

Comment on find out the way program was called.
Re: find out the way program was called.
by Zaxo (Archbishop) on Apr 09, 2004 at 00:47 UTC

    If the program knows its own name, $0 may help.

    After Compline,
    Zaxo

Re: find out the way program was called.
by tilly (Archbishop) on Apr 09, 2004 at 01:14 UTC
    if ($0 eq __FILE__) { print "Called directly\n"; } else { print "Loaded in a library\n"; }
Re: find out the way program was called.
by esskar (Deacon) on Apr 09, 2004 at 01:22 UTC
    perldoc -f caller is maybe also a good hint.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://343808]
Approved by TStanley
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (17)
As of 2014-07-11 15:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (230 votes), past polls