cmd line parsing emulating sv[kn]

Matthew Lawrence matthew.lawrence at ehsbrann.com
Thu Feb 2 10:26:50 GMT 2006


Paul Makepeace wrote:
> I have a script where I'd like to emulate svn's -r option. It goes like,
>   -r 1676
>   -r1676 (i.e. whitespace not significant)
>   -r168:200 (I can probably manage to parse out the two numbers...)
> 
> I've used Getopt::Long (since I know it) with GetOptions("r=s" => \$revs)
> but Go::L seems to require a space between switch & arg which is confusing
> for anyone using sv[kn].
> 
> Any suggestions which module to use?
> 
> Is there a Giant List of CPAN CLI Parsers and Their Features anywhere? 
> 

use Getopt:::Long qw( :config bundling );

seems to work

$ perl -MGetopt::Long=:config,bundling -le 'GetOptions("r=s"=>\$r);print
$r' -- -r125
125

Matt


More information about the london.pm mailing list