in reply to Storing multiple arguments in a data structure that allows for future expansion

I use a hash for the options whose keys are option letters and whose values can be either a scalar for a single or empty value or an array reference for multiple values, e.g.:
use Getopt::Std; my %opt; getopt('abc',\%opt); Multivalued(\%opt); #... sub Multivalued { # convert lists to array refs. my $href = shift; while( my ($k, $v ) = each %$href ) { my @anon = split /\,/, $v or next; $href -> { $k } = \@anon; } }
And to iterate the combinations of the arrays, see Math::Combinatorics.

Update: and if you have to support protected commas in quotes, instead of just splitting, parse with something like Text::Csv::Simple

__________________________________________________________________________________

^M Free your mind!

  • Comment on Re: Storing multiple arguments in a data structure that allows for future expansion
  • Download Code