.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
.\" ========================================================================
.de Sh \" Subsection heading
.de Sp \" Vertical space (when we can't use .PP)
.de Vb \" Begin verbatim text
.de Ve \" End verbatim text
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
. tm Index:\\$1\t\\n%\t"\\$2"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. \" simple accents for nroff and troff
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
.\" ========================================================================
.TH PerlIO 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide"
PerlIO \- On demand loader for PerlIO layers and root of PerlIO::* name space
\& open($fh,"<:crlf", "my.txt"); # portably open a text file for reading
\& open($fh,"<","his.jpg"); # portably open a binary file for reading
\& PERLIO=perlio perl ....
When an undefined layer 'foo' is encountered in an \f(CW\*(C`open\*(C'\fR or
\&\f(CW\*(C`binmode\*(C'\fR layer specification then C code performs the equivalent of:
The perl code in PerlIO.pm then attempts to locate a layer by doing
Otherwise the \f(CW\*(C`PerlIO\*(C'\fR package is a place holder for additional
PerlIO related functions.
The following layers are currently defined:
Low level layer which calls \f(CW\*(C`read\*(C'\fR, \f(CW\*(C`write\*(C'\fR and \f(CW\*(C`lseek\*(C'\fR etc.
Layer which calls \f(CW\*(C`fread\*(C'\fR, \f(CW\*(C`fwrite\*(C'\fR and \f(CW\*(C`fseek\*(C'\fR/\f(CW\*(C`ftell\*(C'\fR etc. Note
that as this is \*(L"real\*(R" stdio it will ignore any layers beneath it and
got straight to the operating system via the C library as usual.
This is a re-implementation of \*(L"stdio\-like\*(R" buffering written as a
PerlIO \*(L"layer\*(R". As such it will call whatever layer is below it for
A layer which does \s-1CRLF\s0 to \*(L"\en\*(R" translation distinguishing \*(L"text\*(R" and
\&\*(L"binary\*(R" files in the manner of MS-DOS and similar operating systems.
(It currently does \fInot\fR mimic MS-DOS as far as treating of Control-Z
as being an end-of-file marker.)
Declares that the stream accepts perl's internal encoding of
characters. (Which really is \s-1UTF\-8\s0 on \s-1ASCII\s0 machines, but is
UTF-EBCDIC on \s-1EBCDIC\s0 machines.) This allows any character perl can
represent to be read from or written to the stream. The UTF-X encoding
is chosen to render simple text parts (i.e. non-accented letters,
digits and common punctuation) human readable in the encoded file.
Here is how to write your native data out using \s-1UTF\-8\s0 (or \s-1UTF\-EBCDIC\s0)
and then read it back in.
\& open(F, ">:utf8", "data.utf");
\& open(F, "<:utf8", "data.utf");
This is the inverse of \f(CW\*(C`:utf8\*(C'\fR layer. It turns off the flag
on the layer below so that data read from it is considered to
be \*(L"octets\*(R" i.e. characters in range 0..255 only. Likewise
on output perl will warn if a \*(L"wide\*(R" character is written
The \f(CW\*(C`:raw\*(C'\fR layer is \fIdefined\fR as being identical to calling
\&\f(CW\*(C`binmode($fh)\*(C'\fR \- the stream is made suitable for passing binary
data i.e. each byte is passed as\-is. The stream will still be
buffered. Unlike earlier versions of perl \f(CW\*(C`:raw\*(C'\fR is \fInot\fR just the
inverse of \f(CW\*(C`:crlf\*(C'\fR \- other layers which would affect the binary nature of
the stream are also removed or disabled.
The implementation of \f(CW\*(C`:raw\*(C'\fR is as a pseudo-layer which when \*(L"pushed\*(R"
pops itself and then any layers which do not declare themselves as suitable
for binary data. (Undoing :utf8 and :crlf are implemented by clearing
flags rather than poping layers but that is an implementation detail.)
As a consequence of the fact that \f(CW\*(C`:raw\*(C'\fR normally pops layers
it usually only makes sense to have it as the only or first element in a
layer specification. When used as the first element it provides
a known base on which to build e.g.
\& open($fh,":raw:utf8",...)
will construct a \*(L"binary\*(R" stream, but then enable \s-1UTF\-8\s0 translation.
A pseudo layer that removes the top-most layer. Gives perl code
a way to manipulate the layer stack. Should be considered
as experimental. Note that \f(CW\*(C`:pop\*(C'\fR only works on real layers
and will not undo the effects of pseudo layers like \f(CW\*(C`:utf8\*(C'\fR.
An example of a possible use might be:
\& binmode($fh,":encoding(...)"); # next chunk is encoded
\& binmode($fh,":pop"); # back to un-encocded
A more elegant (and safer) interface is needed.
.Sh "Alternatives to raw"
.IX Subsection "Alternatives to raw"
To get a binary stream an alternate method is to use:
this has advantage of being backward compatible with how such things have
had to be coded on some platforms for years.
To get an un-buffered stream specify an unbuffered layer (e.g. \f(CW\*(C`:unix\*(C'\fR)
\& open($fh,"<:unix",$path)
.Sh "Defaults and how to override them"
.IX Subsection "Defaults and how to override them"
If the platform is MS-DOS like and normally does \s-1CRLF\s0 to \*(L"\en\*(R"
translation for text files then the default layers are :
(The low level \*(L"unix\*(R" layer may be replaced by a platform specific low
Otherwise if \f(CW\*(C`Configure\*(C'\fR found out how to do \*(L"fast\*(R" \s-1IO\s0 using system's
stdio, then the default layers are :
Otherwise the default layers are
These defaults may change once perlio has been better tested and tuned.
The default can be overridden by setting the environment variable
\&\s-1PERLIO\s0 to a space separated list of layers (unix or platform low level
layer is always pushed first).
This can be used to see the effect of/bugs in the various layers e.g.
\& PERLIO=stdio ./perl harness
\& PERLIO=perlio ./perl harness
Nick Ing-Simmons <nick@ing\-simmons.net>
\&\*(L"binmode\*(R" in perlfunc, \*(L"open\*(R" in perlfunc, perlunicode, Encode