use warnings; ## Debug file to be translated $filetotranslate = "test.txt"; ## Debug file with translated from Spanish to English $fileout3="debug.txt"; open (FILEIN3, $filetotranslate) or die "Can't open debug file.\n"; open (FILEOUT3, ">$fileout3") or die "Can't open output file.\n"; $langhash{'dígito verificador incorrecto.'} = 'digit incorrect.'; while ($linein3 = ) { if ($linein3 =~ /##\s*([^#]+?)\s*##/){ if (exists $langhash{$1}){ $linein3=~ s/##\s*([^#]+?)\s*##/##$langhash{$1}##/; print "$linein3"; } else { print "$linein3"; }}} close(FILEIN3); close(FILEOUT3);