##
$curroption = $1 if s/^([A-Z]+) //;
####
# at top of program
my @options = qw/on except some more options/;
my $opt_string = join '|', @options;
my $opt_pattern = qr/^($opt_string)\s+/i;
# instead of your line
$curroption = $1 if s/$opt_pattern//;
####
push @{$options{$curroption}}, split(/,\s*/);
####
while (my ($option, $val_ref) = each %options) {
print "$option -- ", join (',',@$val_ref), "\n";
}