in reply to Loop through global substitution
while (s/this/that/g) { push @matches, $&; } [download]
while (s/this/that/gp) { push @matches, ${^MATCH}; } [download]
Update: Thought it was m//g.