while ( $enum_types =~ m/('(.*?)'|([^']*?))($|,\s*)/g ) { my $match = $3 || $2; print qq[\n] if $match; }