If your substitutions are working fine (no word-boundary issues), but just taking a long time (understandable, iterating through two arrays for substitutions on each file line), perhaps the following will be helpful:
my $TestText;
{
local $/;
open( my $in, '<', "Test.txt" ) or die "cannot open Test.txt $!";
$TestText = <$in>;
close $in;
}
$TestText =~ s/\Q$_\E/$hash{$_}/g for keys %hash;
open( my $out, '>', "TestFinal.txt" ) or die "cannot create TestFinal
+$!";
print $out $TestText;
close $out;
This reads the entire file into a scalar, so substitutions are done on the entire file's contents. This also uses a hash's key/value pairs instead of different array element pairs, so you'll need to initialize the hash (%hash) accordingly for the three substitution pairs.
Hope this helps!
Edit: my $TestText ... to $TestText ... in the file slurp block and quotemeta \Q$_\E. |