[tpm] Command line option processing

Adam Prime adam.prime at utoronto.ca
Sat Jan 5 21:38:58 PST 2008


Take a look at Getopt::Long::Descriptive.  I saw a talk at PPW given by 
rjbs about App::Cmd where he extolled the virtues of this particular 
module, and i used it for a script at work recently have to to agree 
that it kicks ass.

http://search.cpan.org/~hdp/Getopt-Long-Descriptive-0.06/lib/Getopt/Long/Descriptive.pm

Adam

arocker at vex.net wrote:
> I'm trying to implement a simple check of a command line option (just
> present or absent, no arguments). The shell equivalent, which works, is:
> 
> while getopts v opt
> do
>     case $opt
>     in
>     v) echo "Hi"
>      ;;
>     esac
> done
> 
> The perl, which doesn't:
> 
> #! /usr/bin/perl
> use warnings;
> use Getopt::Std;
> 
> getopt ("v");           # primitive help facility -v is only option
> 
> if ( $Getopt::Std::opt_v ) {
>     print Hi\n";
> }
> 
> and changing the test to if ( $opt ) doesn't do any better.
> 
> I've delved into the Camel, the Cookbook, Nutshell and every other
> grimoire I can find, so public humiliation is the only route left. What
> idiotic error am I making?
> 
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm



More information about the toronto-pm mailing list