I wish arg parser can put same option's args into an array like this;
use Getopt::xxx; getopts('e:'; \%options); if (ref $options{e} eq 'ARRAY'){ print 'you got e args with', $options{e}->@*; }else { print 'your e arg is ', $options{e} }
I can run like myscript.pl -e 'a' -e 'b' to get 'you got e args with a b'.what module is designed to do such thing.

ADDED

I write my own argparser to keep order and add same option args:)

my $all_options = "xp:b:f:s:"; my @s_options = $all_options =~ /[^:](?=:)/g; my @n_options = $all_options =~ /[^:](?!:)/g; my (@options, %options, $need); sub parsearg($$){ my ($index, $arg) = @_; if ($arg !~ /^-/){ return 1 if $index ne $need; } foreach (@s_options){ if ( $arg eq '-'.$_){ push @options, [$_, $ARGV[$index + 1]]; $need = $index + 1; return 0 } } foreach (@n_options){ if ($arg eq '-'.$_){ $options{$_} = 1; $need = $index; return 0 } } } while (my ($index, $argv) = each @ARGV){ last if parsearg $index, $argv; } my @files = splice @ARGV, $need + 1;

In reply to Closed:how to argparse same option to array instead of overwrite by vincentaxhe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.