in reply to Re: corrupted print output
in thread corrupted print output

\n is meant to be portable in Perl. Perl should make the right decision about what the underlying ascii value of \n should be. The sticky point for me has been in processing text files on one OS that have been generated on another OS that uses a different new line ascii combination.

I have run into an issue with chomp in this case. String::Util offers a replacement for this case in fullchomp, though it's simple enough to write one yourself.

Replies are listed 'Best First'.
Re^3: corrupted print output
by onelesd (Pilgrim) on Sep 29, 2011 at 22:55 UTC

    But does Perl behave the same way when $\ is set (the default is undef)? I don't have a Windows machine to test on, but I would assume since he told Perl the newline should be a "\n" that Perl would respect his wishes.

    One thing OP: are you viewing your output file in Notepad? If so, try Wordpad and see how it looks.

      Thanks for everyone's reponse. The portion shown above is taken from notepad. I also transfered the file to a unix box and got the last line of the file (it was too big to open), it was a continous line. The top portion showed ^M at the end of each line.