greenhorn has asked for the wisdom of the Perl Monks concerning the following question:
Does anyone know a clean way to test for
DOS v. UNIX EOL in a text file (using Perl) ? It seems
that (chop($UnixLine) == chop($DOSLine))returns true =-(
No one replied. I thought: hey, I might be a mere newbie, but I'll bet I can figure this out.
Wrong. :) I made some small test files with both <CR><LF> line endings and <LF>-only line endings. Then I watched the results of extracting only those characters from each line in the Perl Builder watch-window. It appeared as if the same characters were returned each time (never mind that one line-ending was \x0D\x0Aand the other was \x0Aalone).
It struck me that using ==there wasn't right; should
he not be using "eq"? Had he in fact
actually compared 0 with 0? (0 == 0does have a certain
ring of truth to it.:)
Does perl for Win32 "internally" convert Unix newlines to <CR><LF>?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Unix \n vs. DOS \n
by Abigail (Deacon) on Jul 15, 2000 at 15:12 UTC | |
|
(Ovid) RE: Unix \n vs. DOS \n
by Ovid (Cardinal) on Jul 15, 2000 at 21:00 UTC | |
|
Re: Unix \n vs. DOS \n
by vkonovalov (Monk) on Jul 15, 2000 at 14:34 UTC | |
|
RE: Unix \n vs. DOS \n
by BigJoe (Curate) on Jul 15, 2000 at 16:34 UTC | |
|
Re: Unix \n vs. DOS \n
by greenhorn (Sexton) on Jul 16, 2000 at 15:20 UTC | |
by chromatic (Archbishop) on Jul 17, 2000 at 01:51 UTC |