RE: Strange behavior with print
I see what ur saying and actually agree with u. But PerlIO automatically (this is one automatic thing I don't like) translates between CRLF and LF on Windows systems. As Jan said setting binmode() will solve ur problem. I personally feel that binmode should be the default everywhere and it should be the programmer's responsibility to decide how to interpret the new line sequences. FYI there are three possible new line sequences, CR, CRLF, and LF, depending on what system ur on. In this day and age it's no longer useful to assume what kind of new line sequences u have based on ur system type. U might very well have to deal with all three at the same time or a contrary type to ur system's native type. It would be nice if there were a :text IO layer that would automatically determine the new line sequence of a particular text file and do the translation, or not, automatically. Currently u have to do an obnoxious manual inspection of the file to know what $/ is. *cough*Jan*cough* ;) HTH At 11:24 AM 12/27/2007 -0500, Bullock, Howard A. wrote: I appear that perl's print command when using a file handle is changing each occurrence of chr(10) to (chr(13) chr(10)). This does not seem to be a helpful or proper action when working with defined literal strings. I can make some sense out of file:///C:/Perl/html/lib/Pod/perlport.html#newlines but do see how that is relevant to literal printing strings. -- REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =-- ...ne cede malis 0100 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Strange behavior with print
On Fri, 28 Dec 2007, Chris Wagner wrote: It would be nice if there were a :text IO layer that would automatically determine the new line sequence of a particular text file and do the translation, or not, automatically. Currently u have to do an obnoxious manual inspection of the file to know what $/ is. *cough*Jan*cough* ;) I'm not sure what you are trying to say here. While reading a file in text mode on Windows, it does not really matter if the lines are terminated by CRLF or LF alone; the CR will be stripped and at the Perl level you always have just a LF, just like on Unix. Files with CR line endings are extremely rare nowadays; as far as I know only Mac OS up to version 9 used those. Everyone using a Mac is running OS X now, which uses LF line endings just like any other Unix-derived system. And anyways, you cannot know the line endings of a file until you have read all of it, which is not really practical for a streaming IO layer. Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs