in reply to performance explanation needed

In the latter case, Perl doesn't have to interpolate variables into the pattern every pass through the loop. Try making your variables qr// expressions instead of strings in the former example, and see if it makes a difference.

Caution: Contents may have been coded under pressure.