$line =~ s/\([^)]+\)//g; my @results = split /,/, $line; print "$_: $results[$_]\n" for 0 .. $#results; #### $string = "abc,def;ghi"; $string =~ /^([^,]+),([^;]+);(.+)$/; #### # Capture a 'non-comma/non-open-paren' string, optionally # followed by parens (not captured), optionally followed by a comma my $s = '([^,(]+)(?:\([^)]+\))?,?'; # Regex consists of 11 of these my $re = $s x 11; my @out = $line =~ /^$re$/; print "$_: $out[$_]\n" for 0 .. $#out;