in reply to Mixing command line arguments

Getopt::Long leaves any unknown data that it finds in @ARGV alone. So you could process whatever's left in @ARGV yourself after sending it through GetOptions():
my($help,$backup,$upd_sybase,$silent); GetOptions('help|h!' => \$help, 'b!' => \$backup, 'u!' => \$upd_sybase, 's!' => \$silent); # assuming it's always key1 value1 key2 value2 in argument list my %other_args = @ARGV; # if your arguments are positional, do this: # my($server,$password) = @ARGV; # called like this: ./foo --silent server bar password blah # yields: # $silent == 1 # $other_args{server} eq "bar"; # $other_args{password} eq "blah";
Update: Added an example for positional arguments since the OP seemed to maybe have wanted that --Brian

Replies are listed 'Best First'.
Re^2: Mixing command line arguments
by Fletch (Bishop) on Nov 02, 2004 at 16:34 UTC

    Another possibility would be to preprocess @ARGV and prefix "--" to any keywords you want to recognize (e.g. turn update into --update) then pass it to Getopt::Long and let it do all the work.

    Update: Changed my example keyword to match original sample invocation.

Re^2: Mixing command line arguments
by ikegami (Patriarch) on Nov 02, 2004 at 17:55 UTC

    Copying @ARGV into a hash doesn't work because "update" has no value. You end up with:

    %other_args = ( update => 'server', weitorsv015 => 'user', ebrine => 'password', secret => undef, );

    instead of

    %other_args = ( update => undef, server => 'weitorsv015', user => 'ebrine', password => 'secret', );