in reply to Regex to extract multiple occurrences

You're confusing the behavious of m//g with m//.

Without /g, a capture (parens) will only return one match (the last one), even if the expression within match more than once (as is the case here). So while the first capture matches both 'apples' and 'pears', only 'pears' is returned for the first capture. What follows is a solution where /g used to return mulitple values for one capture:

my (@rep) = /It contains ([^.]*)\./ && $1 =~ /\G(\S[^,]*)(?:,\s*)?/g;

But you might as well use:

my (@rep) = /It contains ([^.]*)\./ && split(/\s*,\s*/, $1);