http://qs321.pair.com?node_id=379666

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
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?

More info.

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

Thanks.