my @script; GetOptions( ... 'call=s' => sub { push @script, [ call_method => $_[1] ] }, 'eval=s' => sub { push @script, [ do_eval => $_[1] ] }, 'out|o=s' => sub { push @script, [ output => $_[1] ] }, '<>' => sub { push @script, [ process_tpl => $_[0] ] }, ) or pod2usage(2); ... sub call_method { ... } sub do_eval { ... } sub output { ... } sub process_tpl { ... } # All the global options are taken care of. Now execute the "script options" # in the order they were given. for (@script) { my ($method, @args)= @$_; $method= main->can($method) or die 'bug'; $method->(@args); }