foreach (qq/frog toad/, qq/man boy/, qq/woman girl/) { my ( $pattern, $substitution) = split /\s/, $_; $foo =~ s/\Q$pattern\E/$substitution/g; } #### my %testhash = ( qw/frog toad man boy woman girl/ ); foreach (keys %testhash) { $foo =~ /\Q$_\E/$testhash{$_}/; }