my %conv = ( '*' => '?', '?' => '#' ); my $conv = quotemeta(join('', keys(%conv))); my $string = 't?e\\\\xt\\\\* with escapes\\*'; my $result = $string; for ($result) { s/(?