Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Getopt:Long arguments that are not (options or option values)

Reply
Thread Tools

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

 
 
nahum_barnea
Guest
Posts: n/a
 
      09-21-2010
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
 
Reply With Quote
 
 
 
 
Wolf Behrenhoff
Guest
Posts: n/a
 
      09-21-2010
On 21.09.2010 19:33, nahum_barnea wrote:
> 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
 
Reply With Quote
 
 
 
 
jl_post@hotmail.com
Guest
Posts: n/a
 
      09-21-2010
On Sep 21, 11:33*am, nahum_barnea <(E-Mail Removed)> wrote:
> 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
 
Reply With Quote
 
Peter Makholm
Guest
Posts: n/a
 
      09-21-2010
nahum_barnea <(E-Mail Removed)> writes:

> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
page.aspx?option - how to detect "option" Kevin Blount ASP .Net 6 11-28-2006 09:21 PM
DHCP relay agent versus Option 3; Routers Option lcorrigan Cisco 2 09-27-2006 05:18 PM
no 'option' in aspx file means 'option'="false"? Cas ASP .Net 5 08-28-2006 10:36 AM
g++ -pg option and -shared option Julien ROUZIERES C++ 1 12-21-2004 02:30 PM



Advertisments