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