in reply to Re^3: Closed:how to argparse same option to array instead of overwrite
in thread Closed:how to argparse same option to array instead of overwrite

yeah, thanks for your code.But I want outputs to be
("fooarray", [123])("bararray",[456])("fooarray",[789])
,Must keep order, there is a chained transform based on it, so I write my argparser.It works fine.
  • Comment on Re^4: Closed:how to argparse same option to array instead of overwrite
  • Download Code

Replies are listed 'Best First'.
Re^5: Closed:how to argparse same option to array instead of overwrite
by NERDVANA (Priest) on Jul 10, 2024 at 05:47 UTC
    Maybe this example is what you're looking for?
    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 o +ptions" # in the order they were given. for (@script) { my ($method, @args)= @$_; $method= main->can($method) or die 'bug'; $method->(@args); }