Unix does the same thing on ttys in canonical mode. C<\015\012>
is commonly referred to as CRLF.
-A common cause of unportable programs is the misuse of chop() to trim
-newlines:
-
- # XXX UNPORTABLE!
- while(<FILE>) {
- chop;
- @array = split(/:/);
- #...
- }
-
-You can get away with this on Unix and Mac OS (they have a single
-character end-of-line), but the same program will break under DOSish
-perls because you're only chop()ing half the end-of-line. Instead,
-chomp() should be used to trim newlines. The L<Dunce::Files> module
-can help audit your code for misuses of chop().
+To trim trailing newlines from text lines use chomp(). With default
+settings that function looks for a trailing C<\n> character and thus
+trims in a portable way.
When dealing with binary files (or text files in binary mode) be sure
to explicitly set $/ to the appropriate value for your file format