Quoth (e-mail address removed) (Alan Curry):
In 5.6 binmode was explicitly documented as unnecessary on sane platforms:
Gradually, the documentation became less honest in its treatment of the
archaic systems. For example the correct and useful statement "modern
operating systems don't care" has been removed, making it officially
necessary to use binmode on files that are binary^H^H^H^H^H^Hnot text.
As of 5.8, it is necessary. Under some circumstances (in particular
5.8.0 in a UTF-8 locale: this default was removed in 5.8.1, but it is
easy to invoke it again) perl will expect files to be in UTF8, or to be
in the locale's character set, unless you specify they are 'not textual'
with binmode.
[A curse be upon whoever started the perverse usage of the word "binary" as
an antonym of "text", as if text files aren't stored in binary form by
computers too!]
They are, of course; but the point is that their binary representation
is not what one cares about. They are conceptually a sequence of
characters, and you don't care if they are stored as ASCII-with-LF,
ASCII-with-CR, ASCII-with-CRLF, EBCDIC, UTF8, or whatever. Perl and the
operating system conspire (not always successfully) to pretend that you
can read and write characters. If you *do* care about the octet-by-octet
content of a file, then you can say so by opening in in 'binary' mode.
As far as I can tell, there is no correct way under the new definitions to
handle files like (raw) PPM, which begins with a few lines of text and then
switches to non-text. Apparently you have to keep a copy of perl 5.005 around
if you want to handle those.
Well, since I sincerely doubt PPM's under DOS use CRLF line terminators
(or CR under Mac Classic), they are effectively 'binary' by Perl's
definitions, and you can read them perfectly well from a binmode :raw
filehandle. <> and the like work perfectly well for reading lines
defined however you choose from binary files.
Ben