in reply to Re: GetOpts::long Multiple Parameters per option
in thread GetOpts::long Multiple Parameters per option
Ok, I see what you mean.
how about this:
#!/usr/bin/perl use v5.10.1; use strict; use warnings; use Getopt::Long; my (@a, @b); my %options = ( 'a' => \@a, 'b' => \@b, ); GetOptions ( 'a=s{2}' => \@a, 'b=s{2}' => \@b, ); say "$options{'a'}->[0], $options{'a'}->[1]"; say "$options{'b'}->[0], $options['b'}->[1]";
the only problem I have with this is defining parameters for %options before building %options with GetOptions
If for instance I needed to have multiple pairs perl flag, i.e.:
Thanks for the assist.$./program -a a1_1 a1_2 -a a2_1 a2_2 -a a3_1 a3_2
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: GetOpts::long Multiple Parameters per option
by broomduster (Priest) on Feb 07, 2011 at 02:24 UTC |