Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: corrupted print output

by onelesd (Pilgrim)
on Sep 29, 2011 at 21:52 UTC ( #928670=note: print w/replies, xml ) Need Help??


in reply to corrupted print output

If you are running on Windows, shouldn't you set $\ = "\r\n"; in your code?

Replies are listed 'Best First'.
Re^2: corrupted print output
by ikegami (Pope) on Sep 30, 2011 at 00:13 UTC
    No. CRLF is converted to LF on read, so CRLF would never match.
Re^2: corrupted print output
by Kc12349 (Monk) on Sep 29, 2011 at 22:33 UTC

    \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.

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://928670]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2018-05-22 03:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?