in reply to Matching a keyword, value and optional comma delimited values

You could always take $3 and do something like:
my $opts = $3; $opts =~ s/\s*,\s*//g;
I think I'd rather do the whole thing in more than one step though, so if there were spaces IN the optional args you have more control over them, and the thing looks simpler:
#!/usr/local/bin/perl -l -w use strict; my $str="abc = def, ghi, jkl"; my ($req, $opts) = split /\s*,\s*/, $str, 2; $opts = '' unless defined $opts; my ($key, $value) = split /\s*=\s*/, $req; my @opts = split /\s*,\s*/, $opts; print qq(key="$key"); print qq(val="$value"); print join(",", map {qq("$_")} @opts);