perl - print automatically writing CR LF rather than LF

I have a Perl script on Windows.

For some reason, Perl is automatically outputting CR LF (\x0d  \x0a) when I only explicitly have when i only have   \x0a in the string.  Help! Driving me nuts.
open FH_temp, ">$tempfile" ;
open FH_input, "<$file";
 
while(<FH_input>){
   $_ =~ s/[\x0a\x0d]//g;   #remove all CR or LF 
   $_ = $_ . "\x0a";                   #add LF
   print FH_temp $_;
}

Open in new window

rmundkowskyAsked:
Who is Participating?
 
lwadwellConnect With a Mentor Commented:
Hi rmundkowsky,

after the open, add

binmode(FH_temp);


lwadwell
0
 
rmundkowskyAuthor Commented:
LOL, know I feel dumb and not nuts!

Thanks, that works I was thinking text mode only applied to input line separators

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.