[Chicago-talk] alternatives to Getopt::Long

Steven Lembark lembark at wrkhors.com
Fri May 7 13:38:32 CDT 2004

-- Mike Fragassi <frag at ripco.com>

> Getopt::Long doesn't seem to have the ability to take command-line
> arguments like
>    --foo a b c --bar 1 2 3

There is now way for it to know that "a b c" is an argument.
No reason you cannot use some extended options for processing
the stuff (lotsawork) or just:

    --foo='a b c';

my @foo = split /\s+/, $cmdline->{foo};

> and, say, give you @foo = qw(a b c) and @bar = (1, 2, 3).  To get that,
> you have to require that the arguments look like one of these:
>    --foo a,b,c --bar 1,2,3  # and split on commas later
>    --foo a --foo b --foo c --bar 1 --bar 2 --bar 3
> Does anyone know of an alternative to Getopt::Long that can handle the
> first example?

You could also use:

    --foo=a --foo=b --foo=c

and get an array referent to begin with (see GO::L doc's for
handling multiples).

Steven Lembark                               2930 W. Palmer
Workhorse Computing                       Chicago, IL 60647
                                            +1 888 359 3508

More information about the Chicago-talk mailing list