Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: question about getopt

by toolic (Bishop)
on Jun 24, 2009 at 16:27 UTC ( [id://774447]=note: print w/replies, xml ) Need Help??


in reply to Re^2: question about getopt
in thread question about getopt

I have several suggestions.

You should probably change 'f' to 'x' in your usage and in your call to getopts. It looks like you have a bug.

You should probably get rid of the @ARGV check because I doubt it does what you think it does. If you pass these 2 options on your command line, '-c foo -x bar', scalar @ARGV will resolve to 4, not 2, as you might expect. Instead, consider checking the return status of the getopts.

I make it a habit to check if an option is defined, just in case '0' is a legal value:

if (defined $options{o})

Consider using the Core module Pod::Usage instead of rolling your own usage handler. I second the recommendation to switch to Getopt::Long.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-19 04:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found