.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" 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<>. .tr \(*W-|\(bv\*(Tr .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . 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 . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" 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. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" 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 .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . 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 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PerlIO 3" .TH PerlIO 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide" .SH "NAME" PerlIO \- On demand loader for PerlIO layers and root of PerlIO::* name space .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& open($fh,"<:crlf", "my.txt"); # portably open a text file for reading .Ve .PP .Vb 2 \& open($fh,"<","his.jpg"); # portably open a binary file for reading \& binmode($fh); .Ve .PP .Vb 2 \& Shell: \& PERLIO=perlio perl .... .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" 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: .PP .Vb 1 \& use PerlIO 'foo'; .Ve .PP The perl code in PerlIO.pm then attempts to locate a layer by doing .PP .Vb 1 \& require PerlIO::foo; .Ve .PP Otherwise the \f(CW\*(C`PerlIO\*(C'\fR package is a place holder for additional PerlIO related functions. .PP The following layers are currently defined: .IP "unix" 4 .IX Item "unix" 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. .IP "stdio" 4 .IX Item "stdio" 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. .IP "perlio" 4 .IX Item "perlio" 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 its operations. .IP "crlf" 4 .IX Item "crlf" 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.) .IP "utf8" 4 .IX Item "utf8" 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. .Sp 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. .Sp .Vb 3 \& open(F, ">:utf8", "data.utf"); \& print F $out; \& close(F); .Ve .Sp .Vb 3 \& open(F, "<:utf8", "data.utf"); \& $in = ; \& close(F); .Ve .IP "bytes" 4 .IX Item "bytes" 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 to a such a stream. .IP "raw" 4 .IX Item "raw" 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. .Sp 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.) .Sp 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. .Sp .Vb 1 \& open($fh,":raw:utf8",...) .Ve .Sp will construct a \*(L"binary\*(R" stream, but then enable \s-1UTF\-8\s0 translation. .IP "pop" 4 .IX Item "pop" 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: .Sp .Vb 5 \& open($fh,...) \& ... \& binmode($fh,":encoding(...)"); # next chunk is encoded \& ... \& binmode($fh,":pop"); # back to un-encocded .Ve .Sp 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: .PP .Vb 2 \& open($fh,"whatever") \& binmode($fh); .Ve .PP this has advantage of being backward compatible with how such things have had to be coded on some platforms for years. .PP To get an un-buffered stream specify an unbuffered layer (e.g. \f(CW\*(C`:unix\*(C'\fR) in the open call: .PP .Vb 1 \& open($fh,"<:unix",$path) .Ve .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 : .PP .Vb 1 \& unix crlf .Ve .PP (The low level \*(L"unix\*(R" layer may be replaced by a platform specific low level layer.) .PP 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 : .PP .Vb 1 \& unix stdio .Ve .PP Otherwise the default layers are .PP .Vb 1 \& unix perlio .Ve .PP These defaults may change once perlio has been better tested and tuned. .PP 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). .PP This can be used to see the effect of/bugs in the various layers e.g. .PP .Vb 3 \& cd .../perl/t \& PERLIO=stdio ./perl harness \& PERLIO=perlio ./perl harness .Ve .SH "AUTHOR" .IX Header "AUTHOR" Nick Ing-Simmons .SH "SEE ALSO" .IX Header "SEE ALSO" \&\*(L"binmode\*(R" in perlfunc, \*(L"open\*(R" in perlfunc, perlunicode, Encode