Posted on 2006-01-18 00:16:50-08 by perlslicker2
pushing options into an array ref. possible?
I'd like to know if its possible to store options in both variables and hash lists. ie:

GetOptions (
'var=s' => \$var,
'list=s%' => \$list # hash list
);

so on the command line i would have these options:
--var some_string --list add=first --list add=second --list add=third

Where each successive 'list add' option will push the value of add into array
ref $list->{'add'}.

I want the resulting data objects to be:
$var = 'some_string'
$list->{'add'}= qw(first second third);

My current setup will clobber the first two instances of '--list add' and only recognize the last '--list add=third' because the value is a straight hash and not a hash list.

Direct Responses: 2609 | Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.