3 # Map layer name to package that defines it
4 my %alias = (encoding => 'Encode');
12 if (exists $alias{$layer})
14 $layer = $alias{$layer}
18 $layer = "${class}::$layer";
20 eval "require $layer";
30 PerlIO - On demand loader for PerlIO layers and root of PerlIO::* name space
34 open($fh,">:crlf","my.txt")
35 open($fh,">:raw","his.jpg")
38 PERLIO=perlio perl ....
42 When an undefined layer 'foo' is encountered in an C<open> or C<binmode> layer
43 specification then C code performs the equivalent of:
47 The perl code in PerlIO.pm then attempts to locate a layer by doing
51 Otherwise the C<PerlIO> package is a place holder for additional PerLIO related
54 The following layers are currently defined:
60 Low level layer which calls C<read>, C<write> and C<lseek> etc.
64 Layer which calls C<fread>, C<fwrite> and C<fseek>/C<ftell> etc.
65 Note that as this is "real" stdio it will ignore any layers beneath it and
66 got straight to the operating system via the C library as usual.
70 This is a re-implementation of "stdio-like" buffering written as a PerlIO "layer".
71 As such it will call whatever layer is below it for its operations.
75 A layer which does CRLF to "\n" translation distinguishing "text" and "binary"
76 files in the manner of MS-DOS and similar operating systems.
80 Declares that the stream accepts perl's internal encoding of characters.
81 (Which really is UTF-8 on ASCII machines, but is UTF-EBCDIC on EBCDIC machines.)
82 This allows any character perl can represent to be read from or written to the
83 stream. The UTF-X encoding is chosen to render simple text parts (i.e.
84 non-accented letters, digits and common punctuation) human readable in the
89 A pseudo-layer which performs two functions (which is messy, but necessary to
90 maintain compatibility with non-PerLIO builds of perl and they way things
91 have been documented elsewhere).
93 Firstly it forces the file handle to be considered binary at that point
96 Secondly in prevents the IO system seaching back before it in the layer specification.
99 open($fh,":raw:perlio"),...)
101 Forces the use of C<perlio> layer even if the platform default, or C<use open> default
102 is something else (such as ":encoding(iso-8859-7)" ) which would interfere with
103 binary nature of the stream.
107 =head2 Defaults and how to override them
109 If the platform is MS-DOS like and normally does CRLF to "\n" translation
110 for text files then the default layers are :
114 (The low level "unix" layer may be replaced by a platform specific low level layer.)
116 Otherwise if C<Configure> found out how to do "fast" IO using system's stdio, then
117 the default layers are :
121 Otherwise the default layers are
125 These defaults may change once perlio has been better tested and tuned.
127 The default can be overridden by setting the environment variable PERLIO
128 to a space separated list of layers (unix or platform low level layer is
129 always pushed first).
130 This can be used to see the effect of/bugs in the various layers e.g.
133 PERLIO=stdio ./perl harness
134 PERLIO=perlio ./perl harness
138 Nick Ing-Simmons E<lt>nick@ing-simmons.netE<gt>
142 L<perlfunc/"binmode">, L<perlfunc/"open">, L<perlunicode>, L<open>