local $_ = q(one, two, "three, four", five, six); my @words = m( \s* # gobble any leading whitespace ( # capture either: "[^"]+" # a group of quoted letters | # or [^,]+ # a group of non-quoted letters, except commas ) (?:,|$) # anchor the match to a comma, or end of string )gx;