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", ...)