Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / PerlIO.3
CommitLineData
86530b38
AT
1.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "PerlIO 3"
132.TH PerlIO 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide"
133.SH "NAME"
134PerlIO \- On demand loader for PerlIO layers and root of PerlIO::* name space
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 1
138\& open($fh,"<:crlf", "my.txt"); # portably open a text file for reading
139.Ve
140.PP
141.Vb 2
142\& open($fh,"<","his.jpg"); # portably open a binary file for reading
143\& binmode($fh);
144.Ve
145.PP
146.Vb 2
147\& Shell:
148\& PERLIO=perlio perl ....
149.Ve
150.SH "DESCRIPTION"
151.IX Header "DESCRIPTION"
152When an undefined layer 'foo' is encountered in an \f(CW\*(C`open\*(C'\fR or
153\&\f(CW\*(C`binmode\*(C'\fR layer specification then C code performs the equivalent of:
154.PP
155.Vb 1
156\& use PerlIO 'foo';
157.Ve
158.PP
159The perl code in PerlIO.pm then attempts to locate a layer by doing
160.PP
161.Vb 1
162\& require PerlIO::foo;
163.Ve
164.PP
165Otherwise the \f(CW\*(C`PerlIO\*(C'\fR package is a place holder for additional
166PerlIO related functions.
167.PP
168The following layers are currently defined:
169.IP "unix" 4
170.IX Item "unix"
171Low level layer which calls \f(CW\*(C`read\*(C'\fR, \f(CW\*(C`write\*(C'\fR and \f(CW\*(C`lseek\*(C'\fR etc.
172.IP "stdio" 4
173.IX Item "stdio"
174Layer 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
175that as this is \*(L"real\*(R" stdio it will ignore any layers beneath it and
176got straight to the operating system via the C library as usual.
177.IP "perlio" 4
178.IX Item "perlio"
179This is a re-implementation of \*(L"stdio\-like\*(R" buffering written as a
180PerlIO \*(L"layer\*(R". As such it will call whatever layer is below it for
181its operations.
182.IP "crlf" 4
183.IX Item "crlf"
184A layer which does \s-1CRLF\s0 to \*(L"\en\*(R" translation distinguishing \*(L"text\*(R" and
185\&\*(L"binary\*(R" files in the manner of MS-DOS and similar operating systems.
186(It currently does \fInot\fR mimic MS-DOS as far as treating of Control-Z
187as being an end-of-file marker.)
188.IP "utf8" 4
189.IX Item "utf8"
190Declares that the stream accepts perl's internal encoding of
191characters. (Which really is \s-1UTF\-8\s0 on \s-1ASCII\s0 machines, but is
192UTF-EBCDIC on \s-1EBCDIC\s0 machines.) This allows any character perl can
193represent to be read from or written to the stream. The UTF-X encoding
194is chosen to render simple text parts (i.e. non-accented letters,
195digits and common punctuation) human readable in the encoded file.
196.Sp
197Here is how to write your native data out using \s-1UTF\-8\s0 (or \s-1UTF\-EBCDIC\s0)
198and then read it back in.
199.Sp
200.Vb 3
201\& open(F, ">:utf8", "data.utf");
202\& print F $out;
203\& close(F);
204.Ve
205.Sp
206.Vb 3
207\& open(F, "<:utf8", "data.utf");
208\& $in = <F>;
209\& close(F);
210.Ve
211.IP "bytes" 4
212.IX Item "bytes"
213This is the inverse of \f(CW\*(C`:utf8\*(C'\fR layer. It turns off the flag
214on the layer below so that data read from it is considered to
215be \*(L"octets\*(R" i.e. characters in range 0..255 only. Likewise
216on output perl will warn if a \*(L"wide\*(R" character is written
217to a such a stream.
218.IP "raw" 4
219.IX Item "raw"
220The \f(CW\*(C`:raw\*(C'\fR layer is \fIdefined\fR as being identical to calling
221\&\f(CW\*(C`binmode($fh)\*(C'\fR \- the stream is made suitable for passing binary
222data i.e. each byte is passed as\-is. The stream will still be
223buffered. Unlike earlier versions of perl \f(CW\*(C`:raw\*(C'\fR is \fInot\fR just the
224inverse of \f(CW\*(C`:crlf\*(C'\fR \- other layers which would affect the binary nature of
225the stream are also removed or disabled.
226.Sp
227The implementation of \f(CW\*(C`:raw\*(C'\fR is as a pseudo-layer which when \*(L"pushed\*(R"
228pops itself and then any layers which do not declare themselves as suitable
229for binary data. (Undoing :utf8 and :crlf are implemented by clearing
230flags rather than poping layers but that is an implementation detail.)
231.Sp
232As a consequence of the fact that \f(CW\*(C`:raw\*(C'\fR normally pops layers
233it usually only makes sense to have it as the only or first element in a
234layer specification. When used as the first element it provides
235a known base on which to build e.g.
236.Sp
237.Vb 1
238\& open($fh,":raw:utf8",...)
239.Ve
240.Sp
241will construct a \*(L"binary\*(R" stream, but then enable \s-1UTF\-8\s0 translation.
242.IP "pop" 4
243.IX Item "pop"
244A pseudo layer that removes the top-most layer. Gives perl code
245a way to manipulate the layer stack. Should be considered
246as experimental. Note that \f(CW\*(C`:pop\*(C'\fR only works on real layers
247and will not undo the effects of pseudo layers like \f(CW\*(C`:utf8\*(C'\fR.
248An example of a possible use might be:
249.Sp
250.Vb 5
251\& open($fh,...)
252\& ...
253\& binmode($fh,":encoding(...)"); # next chunk is encoded
254\& ...
255\& binmode($fh,":pop"); # back to un-encocded
256.Ve
257.Sp
258A more elegant (and safer) interface is needed.
259.Sh "Alternatives to raw"
260.IX Subsection "Alternatives to raw"
261To get a binary stream an alternate method is to use:
262.PP
263.Vb 2
264\& open($fh,"whatever")
265\& binmode($fh);
266.Ve
267.PP
268this has advantage of being backward compatible with how such things have
269had to be coded on some platforms for years.
270.PP
271To get an un-buffered stream specify an unbuffered layer (e.g. \f(CW\*(C`:unix\*(C'\fR)
272in the open call:
273.PP
274.Vb 1
275\& open($fh,"<:unix",$path)
276.Ve
277.Sh "Defaults and how to override them"
278.IX Subsection "Defaults and how to override them"
279If the platform is MS-DOS like and normally does \s-1CRLF\s0 to \*(L"\en\*(R"
280translation for text files then the default layers are :
281.PP
282.Vb 1
283\& unix crlf
284.Ve
285.PP
286(The low level \*(L"unix\*(R" layer may be replaced by a platform specific low
287level layer.)
288.PP
289Otherwise if \f(CW\*(C`Configure\*(C'\fR found out how to do \*(L"fast\*(R" \s-1IO\s0 using system's
290stdio, then the default layers are :
291.PP
292.Vb 1
293\& unix stdio
294.Ve
295.PP
296Otherwise the default layers are
297.PP
298.Vb 1
299\& unix perlio
300.Ve
301.PP
302These defaults may change once perlio has been better tested and tuned.
303.PP
304The default can be overridden by setting the environment variable
305\&\s-1PERLIO\s0 to a space separated list of layers (unix or platform low level
306layer is always pushed first).
307.PP
308This can be used to see the effect of/bugs in the various layers e.g.
309.PP
310.Vb 3
311\& cd .../perl/t
312\& PERLIO=stdio ./perl harness
313\& PERLIO=perlio ./perl harness
314.Ve
315.SH "AUTHOR"
316.IX Header "AUTHOR"
317Nick Ing-Simmons <nick@ing\-simmons.net>
318.SH "SEE ALSO"
319.IX Header "SEE ALSO"
320\&\*(L"binmode\*(R" in perlfunc, \*(L"open\*(R" in perlfunc, perlunicode, Encode