in reply to Getting selected options from GetOptions()

E.g.:
if ($a) { print "a was selected\n"; }
If you want something more robust, I suggest a hash, e.g. (not tested):
my %opts; GetOptions(map { ($_ => \$opts{$_}) } "a".."z"); $opts{$_} and print "$_ was selected\n" for "a".."z";

Replies are listed 'Best First'.
Re^2: Getting selected options from GetOptions()
by Anonymous Monk on Dec 16, 2009 at 20:44 UTC
    The problem is that , there are more than 30 options, and I dont want to write like 30 if statements to get the selected options. Is there any effective way to find this?

    Thanks,
    Tom

      Using runrig's example:

      my %opts; GetOptions(map { ($_ => \$opts{$_}) } "a".."z"); my @selected = grep { $opts{$_} } keys %opts;
      Thanks much.
      -Tom