in reply to Detection of main script / libraries

I think __PACKAGE__ is what you want.

$ perl -e'print __PACKAGE__,$/' main $

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: Detection of main script / libraries
by shmuelp (Initiate) on Mar 25, 2002 at 04:48 UTC
    __PACKAGE__ always prints out the current package, and in a script (that doesn't declare its own package) that has been included via "do" or "require", __PACKAGE__ still is "main". An inelegant solution is a create a global variable when the first script begins it's main path of execution, and check for that in each submodule. But the elegant way escapes me.