binmode 
binmodeFILEHANDLE,IOLAYERbinmodeFILEHANDLE
This function arranges for the
FILEHANDLE to have the semantics specified by
the IOLAYER argument. If
IOLAYER is omitted, binary (or “raw”)
semantics are applied to the filehandle. If
FILEHANDLE is an expression, the value is
taken as the name of the filehandle or a reference to a filehandle, as
appropriate. The function returns true if it succeeded, false
otherwise.
The binmode function should be
called after the open but before any
I/O is done on the filehandle. The only way to reset the mode on a
filehandle is to reopen the file, since the various layers may have
treasured up various bits and pieces of data in various buffers. This
restriction may be relaxed in the future.
In olden days, binmode was used
primarily on operating systems whose runtime libraries distinguished
text from binary files. On those systems, the purpose of binmode was to turn off the default text
semantics. However, with the advent of Unicode and its many different
storage encodings, programs on all systems must take some cognizance of
the distinction.
These days there is only one kind of binary file (as far as Perl is concerned), but there are many kinds of text files, which Perl would also like to treat in a single way. So Perl has a single internal format for Unicode text, UTF-8.
Since there are many kinds of text files, text files often need to be translated ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access