in reply to Unix \n vs. DOS \n
I created a four-line text file in which two lines had CR/LF line endings and the other two had LF-only line endings. Then, a small script that reads each line of the file. Following is the business end of it. (All lines in the file have "F" immediately before the line boundary.)
# TWO LINES IN THE FILE MEET THE FOLLOWING CRITERIA: print "ends CRLF\n" if /F\x0D\x0A$/; print "ends CRLF\n" if /F\r\n/; print "contains CR\n" if /\x0D/; print "contains CR\n" if /\r/; # AND THE OTHER TWO LINES IN THE FILE MATCH THIS: print "ends LF only\n" if /F\x0A$/;
But the script printed only this: ends LF only. It never did print ends CRLF or contains CR.
If perl doesn't make some internal translation of the carriage-return characters when it's reading a file, then why that result? Are the tests above not sufficient?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(chromatic) RE: Re: Unix \n vs. DOS \n
by chromatic (Archbishop) on Jul 17, 2000 at 01:51 UTC |