my $replacements = [ ['S\&O 400', 'S&P 500'], ['\b400\b', '200'], # ... (or read these match/replace literals from a file) ] # this provides a stable, consistent order of application for my $edit ( @$replacements ) { s/$$edit[0]/$$edit[1]/; }