Is there a way to determine if the current file is the one being executed in Perl source? In Python we do this with the following construct:
if __name__ == \'__m
unless caller
is good, but a more direct parallel, as well as a more explicit check, is:
use English qw<$PROGRAM_NAME>;
if ( $PROGRAM_NAME eq __FILE__ ) {
...
}
Just thought I'd put that out there.
EDIT
Keep in mind that $PROGRAM_NAME
(or '$0
') is writable, so this is not absolute. But, in most practice--except on accident, or rampaging modules--this likely won't be changed, or changed at most locally within another scope.