Install Perl 5.8.8
[msysgit.git] / mingw / html / ext / IO / lib / IO / File.html
blobde28ac65a4b36372b577dcc54b24d6470f359ff0
1 <?xml version="1.0" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>IO::File - supply object methods for filehandles</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <link rev="made" href="mailto:" />
8 </head>
10 <body style="background-color: white">
11 <table border="0" width="100%" cellspacing="0" cellpadding="3">
12 <tr><td class="block" style="background-color: #cccccc" valign="middle">
13 <big><strong><span class="block">&nbsp;IO::File - supply object methods for filehandles</span></strong></big>
14 </td></tr>
15 </table>
17 <p><a name="__index__"></a></p>
18 <!-- INDEX BEGIN -->
20 <ul>
22 <li><a href="#name">NAME</a></li>
23 <li><a href="#synopsis">SYNOPSIS</a></li>
24 <li><a href="#description">DESCRIPTION</a></li>
25 <li><a href="#constructor">CONSTRUCTOR</a></li>
26 <li><a href="#methods">METHODS</a></li>
27 <li><a href="#note">NOTE</a></li>
28 <li><a href="#see_also">SEE ALSO</a></li>
29 <li><a href="#history">HISTORY</a></li>
30 </ul>
31 <!-- INDEX END -->
33 <hr />
34 <p>
35 </p>
36 <h1><a name="name">NAME</a></h1>
37 <p>IO::File - supply object methods for filehandles</p>
38 <p>
39 </p>
40 <hr />
41 <h1><a name="synopsis">SYNOPSIS</a></h1>
42 <pre>
43 use IO::File;</pre>
44 <pre>
45 $fh = new IO::File;
46 if ($fh-&gt;open(&quot;&lt; file&quot;)) {
47 print &lt;$fh&gt;;
48 $fh-&gt;close;
49 }</pre>
50 <pre>
51 $fh = new IO::File &quot;&gt; file&quot;;
52 if (defined $fh) {
53 print $fh &quot;bar\n&quot;;
54 $fh-&gt;close;
55 }</pre>
56 <pre>
57 $fh = new IO::File &quot;file&quot;, &quot;r&quot;;
58 if (defined $fh) {
59 print &lt;$fh&gt;;
60 undef $fh; # automatically closes the file
61 }</pre>
62 <pre>
63 $fh = new IO::File &quot;file&quot;, O_WRONLY|O_APPEND;
64 if (defined $fh) {
65 print $fh &quot;corge\n&quot;;</pre>
66 <pre>
67 $pos = $fh-&gt;getpos;
68 $fh-&gt;setpos($pos);</pre>
69 <pre>
70 undef $fh; # automatically closes the file
71 }</pre>
72 <pre>
73 autoflush STDOUT 1;</pre>
74 <p>
75 </p>
76 <hr />
77 <h1><a name="description">DESCRIPTION</a></h1>
78 <p><code>IO::File</code> inherits from <code>IO::Handle</code> and <code>IO::Seekable</code>. It extends
79 these classes with methods that are specific to file handles.</p>
80 <p>
81 </p>
82 <hr />
83 <h1><a name="constructor">CONSTRUCTOR</a></h1>
84 <dl>
85 <dt><strong><a name="item_new">new ( FILENAME [,MODE [,PERMS]] )</a></strong>
87 <dd>
88 <p>Creates an <code>IO::File</code>. If it receives any parameters, they are passed to
89 the method <a href="#item_open"><code>open</code></a>; if the open fails, the object is destroyed. Otherwise,
90 it is returned to the caller.</p>
91 </dd>
92 </li>
93 <dt><strong><a name="item_new_tmpfile">new_tmpfile</a></strong>
95 <dd>
96 <p>Creates an <code>IO::File</code> opened for read/write on a newly created temporary
97 file. On systems where this is possible, the temporary file is anonymous
98 (i.e. it is unlinked after creation, but held open). If the temporary
99 file cannot be created or opened, the <code>IO::File</code> object is destroyed.
100 Otherwise, it is returned to the caller.</p>
101 </dd>
102 </li>
103 </dl>
105 </p>
106 <hr />
107 <h1><a name="methods">METHODS</a></h1>
108 <dl>
109 <dt><strong><a name="item_open">open( FILENAME [,MODE [,PERMS]] )</a></strong>
111 <dt><strong>open( FILENAME, IOLAYERS )</strong>
113 <dd>
114 <p><a href="#item_open"><code>open</code></a> accepts one, two or three parameters. With one parameter,
115 it is just a front end for the built-in <a href="#item_open"><code>open</code></a> function. With two or three
116 parameters, the first parameter is a filename that may include
117 whitespace or other special characters, and the second parameter is
118 the open mode, optionally followed by a file permission value.</p>
119 </dd>
120 <dd>
121 <p>If <code>IO::File::open</code> receives a Perl mode string (``&gt;'', ``+&lt;'', etc.)
122 or an ANSI C <code>fopen()</code> mode string (``w'', ``r+'', etc.), it uses the basic
123 Perl <a href="#item_open"><code>open</code></a> operator (but protects any special characters).</p>
124 </dd>
125 <dd>
126 <p>If <code>IO::File::open</code> is given a numeric mode, it passes that mode
127 and the optional permissions value to the Perl <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_sysopen"><code>sysopen</code></a> operator.
128 The permissions default to 0666.</p>
129 </dd>
130 <dd>
131 <p>If <code>IO::File::open</code> is given a mode that includes the <code>:</code> character,
132 it passes all the three arguments to the three-argument <a href="#item_open"><code>open</code></a> operator.</p>
133 </dd>
134 <dd>
135 <p>For convenience, <code>IO::File</code> exports the O_XXX constants from the
136 Fcntl module, if this module is available.</p>
137 </dd>
138 </li>
139 <dt><strong><a name="item_binmode">binmode( [LAYER] )</a></strong>
141 <dd>
142 <p><a href="#item_binmode"><code>binmode</code></a> sets <a href="#item_binmode"><code>binmode</code></a> on the underlying <code>IO</code> object, as documented
143 in <code>perldoc -f binmode</code>.</p>
144 </dd>
145 <dd>
146 <p><a href="#item_binmode"><code>binmode</code></a> accepts one optional parameter, which is the layer to be
147 passed on to the <a href="#item_binmode"><code>binmode</code></a> call.</p>
148 </dd>
149 </li>
150 </dl>
152 </p>
153 <hr />
154 <h1><a name="note">NOTE</a></h1>
155 <p>Some operating systems may perform <a href="#item_new"><code>IO::File::new()</code></a> or <a href="#item_open"><code>IO::File::open()</code></a>
156 on a directory without errors. This behavior is not portable and not
157 suggested for use. Using <code>opendir()</code> and <code>readdir()</code> or <code>IO::Dir</code> are
158 suggested instead.</p>
160 </p>
161 <hr />
162 <h1><a name="see_also">SEE ALSO</a></h1>
163 <p><a href="file://C|\msysgit\mingw\html/pod/perlfunc.html">the perlfunc manpage</a>,
164 <a href="file://C|\msysgit\mingw\html/pod/perlop.html#i_o_operators">I/O Operators in the perlop manpage</a>,
165 <a href="file://C|\msysgit\mingw\html/lib/IO/Handle.html">the IO::Handle manpage</a>,
166 <a href="file://C|\msysgit\mingw\html/lib/IO/Seekable.html">the IO::Seekable manpage</a>,
167 <a href="file://C|\msysgit\mingw\html/lib/IO/Dir.html">the IO::Dir manpage</a></p>
169 </p>
170 <hr />
171 <h1><a name="history">HISTORY</a></h1>
172 <p>Derived from FileHandle.pm by Graham Barr &lt;<em><a href="mailto:gbarr@pobox.com">gbarr@pobox.com</a></em>&gt;.</p>
173 <table border="0" width="100%" cellspacing="0" cellpadding="3">
174 <tr><td class="block" style="background-color: #cccccc" valign="middle">
175 <big><strong><span class="block">&nbsp;IO::File - supply object methods for filehandles</span></strong></big>
176 </td></tr>
177 </table>
179 </body>
181 </html>