|XP is just a number|
Dual personality: Module and scriptby Anonymous Monk
|on Aug 03, 2004 at 14:45 UTC||Need Help??|
Anonymous Monk has asked for the
wisdom of the Perl Monks concerning the following question:
I want a module to detect if it was loaded by "require" or "system". Can this be done in elegant way, or just adding and checking different argument passed by the caller?
I have working programs, where a Perl script, loaded from command line, will later "require" a module, and jump to a subroutine inside the module, and the rest of the package thereafter.
I checked that Perl will run a .pm script from command line, not neccessary have to be .pl.
I want to add to the .pm file more code that will only be executed if loaded from command line or "system" because I want to share most of the code in the module. The functionality of the module should stay as before. So I guess I need an "if statemt" at the beginning to check who was calling, but check what? :(
I am on Windows XP, Active State v5.8.3 built for MSWin32-x86-multi-thread