Getopt:Long arguments that are not (options or option values)

N

nahum_barnea

Hi Group.
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.

For example:

../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?

Thanks,
NAHUM
 
W

Wolf Behrenhoff

Hi Group.
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.

For example:

./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 .

Look at @ARGV.

Wolf
 
J

jl_post

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.

For example:

./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  .


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.

-- Jean-Luc
 
P

Peter Makholm

nahum_barnea said:
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.

Read the documentation for the module and look for the 'pass_through'
configuration option.

//Makholm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top