use strict; use warnings; my $text = "I will not stir from this place, do what they can."; my %replacements = ( "will not" => "won't", "stir" => "move", "this place" => "here", "do what they can" => "let them try"); my $pattern = join "|", map quotemeta, keys %replacements; print "The pattern is: $pattern\n"; my $replaced = $text =~ s/($pattern)/$replacements{$1}/gr; print $replaced;