|
Posted by John on April 23, 2008, 7:56 am
Please log in for more thread options
>I want to read a file line-by line and write it line by line to another file.
>Regarless of environment I want newline start with DOS's \x0d\x0a
>
>Here's the code snippet:
>
$ii=open(MYHAN,"<file01.htm");
open(MYHAN2,">>receive.htm");
binmode(MYHAN);
binmode(MYHAN2);
while ($line=<MYHAN>)
{
chomp($line);
$line=~s/\x0d//g; # probably unnecessary
$line=~s/\x0a//g;
print MYHAN2 $line."testing\x0d\x0a";
}
close MYHAN;
close MYHAN2;
oops there was a typo - I had cut the code from another source but problem
remains teh same.
>
>
>The problem is that I get in "receive.txt" I get ending
>"balhblahtesting[CR][CR][LF]" where [CR] mean carriage return and [LF] line
feed.
>
>Why is this happening? I've chomped and ~s'd the $line. I've also binmoded both
>file handles for good measure.
|