Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Battling Getopt::Long

by Tomte (Priest)
on May 11, 2004 at 12:33 UTC ( [id://352419]=note: print w/replies, xml ) Need Help??


in reply to Battling Getopt::Long

Change

my %opts = (); my %opts=(GetOptions( 'help|?' => \$help, 'server' => \$server, 'user' => \$user, 'password' => \$password ));
to
GetOptions( 'help:+' => \$help, 'server=s' => \$server, 'user=s' => \$user, 'password=s' => \$password, );
and use the variables directly, not the hash.

Edit: fixed the code according to the follow-up postings.

should get you started

regards,
tomte


An intellectual is someone whose mind watches itself.
-- Albert Camus

Replies are listed 'Best First'.
Re: Re: Battling Getopt::Long
by Smaug (Pilgrim) on May 11, 2004 at 12:53 UTC
    Thanks Tomte!! That's working great!!
    From your code could you explain the 'help:i'.
    From what I have read to date, the : means it is optional and the i sets it as an integer.
    Does that mean that if it exists, it will set $help to 1 otherwise it will be 0?
    Thanks again!

      ah no, my mistake...
      change the i to a + and test for $help>0

      regards,
      tomte


      An intellectual is someone whose mind watches itself.
      -- Albert Camus

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://352419]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-24 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found