http://www.perlmonks.org?node_id=939536


in reply to Nested grouping or capturing inside capturing

$+ helps a little:

#print "$1-$2-".($4 || $3) if /(\w+)\s(\w+)\s("([^"]+)"|(\w+))/; print "$1-$2-$+" if /(\w+)\s(\w+)\s("([^"]+)"|(\w+))/;