for $count (0..52) { my $pattern = quotemeta($array1{$count}); $sometext =~ s/$pattern/$array2{$count}/g; }