The trick is to use the caller function. Example:
a.pl: unless (caller[0] =~ /main/) { print "a was called directly\n"; }
b.pl:do "a.pl";
Now, if a.pl is called directly, it will print the message, but if b.pl is called first, and a.pl is called from b.pl, it will not print the message.
In reply to Re: Detection of main script / libraries
by shmuelp
in thread Detection of main script / libraries
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |