in reply to Re: Detection of main script / libraries
in thread Detection of main script / libraries
As a concrete example of this:
My::Standalone.pmunless (caller() =~ /main/) { My::Standalone->run(); } else { @My::Standalone::EXPORT = qw[run]; } package My::Standalone; use strict; use warnings; use Exporter; our @ISA = qw(Exporter); sub run { my($self) = shift || caller(); print "See, I do something\n"; } 1;
You can then call this with any of the following:
or include it in a script:
test.pl#!perl use strict; use warnings; use My::Standalone; print "Do something\n"; run(); # Call the run function exit;
|
|---|