map { my $t = $2 || $3; print "<$t\n"; }
m/('(.*?)'|([^']*?))($|,\s*)/g;
In list context, a global match that contains capturing parentheses returns a flattened list of all captured parts (three per match in your example) for all matches. That is the list you're mapping over, and it is built before the map even starts. The capture variables (
$1, $2) you are refering to in the map block are the ones left over from the last of possibly many global matches.
In other words, map will run over a list three times as long as the number of global matches, but $2 and $3 will be the same during all iterations. That won't do at all what you expect.
Anno