open
use open IN => ":crlf", OUT => ":raw"; use open OUT => ":utf8"; use open IO => ":encoding(iso–8859–7)"; use open IO => ":locale"; use open ":encoding(utf8)"; use open ":locale"; use open ":encoding(iso–8859–7)"; use open ":std";
The open pragma declares one or more default layers (formerly called
disciplines) for I/O operations, but only if your
Perl binary was built with PerlIO. Any open and readpipe (that is, qx// or backticks) operators found within the
lexical scope of this pragma that do not specify their own layers will use
the declared defaults. Neither open
with an explicit set of layers, nor sysopen under any circumstances, is influenced
by this pragma.
There are several layers to choose from:
:bytesThis layer treats the data as characters with codepoints in the range 0 to 255. This is the inverse of the
:utf8layer. This is not the same thing as:raw, though, since this still may do CRLF processing under Windows systems.:crlfThis layer corresponds to the text mode, in which line endings are translated to or from the native line endings. This is a no-op on a platform where
binmodeis a no-op. This layer is available without PerlIO.:encoding(ENCODING)This layer specifies any encoding supported by the
Encodemodule, directly or indirectly.:localeThis layer decodes or encodes its data according to the locale settings.
:rawThis pseudolayer turns off any layer below it that would interpret the data as other than binary data. This is a no-op on a platform where
binmodeis a ...
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