CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
passing multiple options through Getopt::Long in perl 5.6 version

 



nibalan
Novice

Jun 13, 2011, 8:14 AM

Post #1 of 5 (740 views)
passing multiple options through Getopt::Long in perl 5.6 version Can't Post

Using Getopt long I am able to pass multiple options as below:

perl myscript.pl --a nisha --b branch --b label

I need to specify --b as many times I want arguments to be passed to that option. We can also it other way by specifying

"b=s{1,}" in the code. So I can call my script in this way:

perl myscript.pl --a nisha --b branch label

But the second method does not work below perl 5.10 version. But my script requirement is such that --b must be specified only once and the arguments has to be passed with space between them. How do I do it? The version I use is 5.6


FishMonger
Veteran / Moderator

Jun 13, 2011, 9:58 AM

Post #2 of 5 (737 views)
Re: [nibalan] passing multiple options through Getopt::Long in perl 5.6 version [In reply to] Can't Post

I'd say that using perl 5.6 is a bigger issue than the Getopt::Long issue. You really should upgrade that to at least 5.10

The "b=s{1,}" syntax is an experimental feature and may not be good to use in production code until it comes out of the experimental phase.

The latest version of Getopt::Long is backwards compatible to perl 5.004, but that doesn't meant the experimental part is also compatible.

IMO, your best solution is to upgrade perl.


nibalan
Novice

Jun 13, 2011, 9:19 PM

Post #3 of 5 (730 views)
Re: [FishMonger] passing multiple options through Getopt::Long in perl 5.6 version [In reply to] Can't Post

I am writing a perl script as part of my project in my office. Every office PC contains 5.6 version. The script I am writing is goin to be used by everyone in my office. So there is no use of just upgrading my system and I cant ask others to do it. Can you please provide a code that brings the output I asked? I couldnt do it


FishMonger
Veteran / Moderator

Jun 14, 2011, 5:46 AM

Post #4 of 5 (727 views)
Re: [nibalan] passing multiple options through Getopt::Long in perl 5.6 version [In reply to] Can't Post

Are you using the same version of Getopt::Long on the 5.6 boxes as you have on the 5.10 box?

If not, then start by upgrading your station to the latest version of the module. If that doesn't fix the problem, then you'll either need to upgrade perl or contact the module author to get his input.
Johan Vromans <jvromans@squirrel.nl>

I don't have the desire to install perl 5.6 and debug this experimental feature.


miller
User

Jun 14, 2011, 9:52 AM

Post #5 of 5 (721 views)
Re: [nibalan] passing multiple options through Getopt::Long in perl 5.6 version [In reply to] Can't Post


In Reply To
I am writing a perl script as part of my project in my office. Every office PC contains 5.6 version. The script I am writing is goin to be used by everyone in my office. So there is no use of just upgrading my system and I cant ask others to do it. Can you please provide a code that brings the output I asked? I couldnt do it


You don't have to limit yourself to perl 5.6 just because the other PC's you want to run this script on only have that version.

Instead, I suggest that you get the latest version of Strawberry Perl, install the latest versions of the cpan modules you want to use, and get your script to work.

After that install PAR::Packer or some other perl to exe method, to pack your script with the perl and modules it needs into an exe that you can run on the other machines without having to actually install anything.

- Miller

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives