my %repl = qw / < < > > foo bar bar foo /; $wrapper =~ s/([<>]|foo|bar)/$repl{$1}/g;