use warnings; use strict; my @repls = ( [ qr/pat1/, 'repl1' ], [ qr/pat2/, 'repl2' ], [ qr/pat3/, 'repl3' ], ); my $txt = <<'EOF'; This is some example (pat1) text which will be (pat3) modified according (pat2) to some replacement (pat2) rules. EOF foreach my $r (@repls) { $txt =~ s/$r->[0]/$r->[1]/eg; } print $txt; __END__ This is some example (repl1) text which will be (repl3) modified according (repl2) to some replacement (repl2) rules.