Of course there are variations of these scheme possible --- you just need the "return 1 if caller" line to distinguish between module code and script-only code.package My::Module; use Getopt::Long; sub process { local @ARGV = @_; # handle command line or named parameter options: GetOptions(...) or die ...; # here follows the rest of the script } return 1 if caller; # This is executed only in "script" mode: process(@ARGV); # In "module" mode I have to write: # use My::Module; # My::Module::process(-bla => "foo", ...)
In reply to Re: Dual personality: Module and script
by eserte
in thread Dual personality: Module and script
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |