This discussion is archived
1 Reply Latest reply: Aug 30, 2012 1:03 AM by EJP RSS

Q: Perl search and replace in file containing Japanese characters

37875 Newbie
Currently Being Moderated
Hello Perl experts

I have a Unicode Text file (saved from Excel) and would like to replace the tabs in that file with commas. I am using the following code but it seems to be changing some of the Japanese characters in the file only in certain files. If needed I can attach the original file but was wondering if there is a better way to do this using Perl only.

open INF, "ST_20120829_102433_AB.txt" ;
open OUTF, ">outf.txt" ;

binmode INF;
binmode OUTF;

while (read (INF, $readbuff, 65535)) {
$readbuff =~ s/$t1/,/g ;
print OUTF $readbuff ;
}
close INF ;
close OUTF ;

Thanks
Arindam

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points