Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
September 21, 2010, 5:33 pm
rate this thread
I use Perl "use Getopt::Long;" .
Now, I know how to get command line options and their values.
But I want to get into a Perl array all the command line arguments
that are NOT options and NOT values.
./myscript.pl -f option_val_of_f -g option_val_of_g arg1 arg2 arg3
I would like to get a Perl array with arg1,arg2,arg3 .
Do you know how to do such stuff?
- Wolf Behrenhoff
September 21, 2010, 5:58 pm
Re: Getopt:Long arguments that are not (options or option values)
Just check @ARGV after you call GetOptions(). Calling GetOptions()
will cause the options (and their values) to be removed from the @ARGV
array, leaving only the non-option-arguments behind.
So then, @ARGV has exactly what you're looking for (but only AFTER
you call GetOptions()).
I hope this helps, Nahum.
- » FAQ 2.4 I copied the perl binary from one machine to another, but scripts don't work.
- — Previous thread in » PERL Discussions