in reply to Re: Why chomp doesn't work?
in thread Why chomp doesn't work?

You're wrong, on Windows/DOS, Perl thinks of "\n" as chr(10), too. It's only that when reading from a text file, thus with binmode disgarded, the contents read from the file is modified so a chr(10) (="\n") is substituted for every chr(13).chr(10) pair in the file.

On printout to a text file handle, the reverse happens: Every chr(10) is replaced by chr(13).chr(10).

The net effect, and the whole point of this elaborate exercise, is that on these platforms, "\n" is a single character too.

Replies are listed 'Best First'.
Re^3: Why chomp doesn't work?
by Fletch (Bishop) on Jun 14, 2004 at 14:14 UTC

    You forgot your </pedant> tag there. :)

    This is correct, in memory it is represented as a single \cJ and the translation (on a filehandle that binmode hasn't been enabled on) to/from \cM\cJ happens when passing through STDIO's claws. See ISSUES / Newlines in perldoc perlport for the gory details.