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} } #### 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;