perlfunc
root
<P>
IO::File - supply object methods for filehandles
<P>
<HR>
<P>
<PRE> use IO::File;
</PRE>
<P>
<PRE> $fh = new IO::File;
if ($fh->open("< file")) {
print <$fh>;
$fh->close;
}
</PRE>
<P>
<PRE> $fh = new IO::File "> file";
if (defined $fh) {
<P>
<CODE>IO::File</CODE> inherits from <CODE>IO::Handle</CODE> and <CODE>IO::Seekable</CODE>. It extends these classes with methods that are specific to file handles.
<P>
<HR>
<H1><A NAME="CONSTRUCTOR">CONSTRUCTOR</A></H1>
<DL>
<DT><STRONG><A NAME="item_new">new ([ ARGS ] )</A></STRONG><P>
<DD>
Creates a <CODE>IO::File</CODE>. If it receives any parameters, they are passed to the method [perlfunc:open|open]; if the open fails, the object is destroyed. Otherwise, it is returned to
the caller.
<P><DT><STRONG><A NAME="item_new_tmpfile">new_tmpfile</A></STRONG><P>
<DD>
Creates an <CODE>IO::File</CODE> opened for read/write on a newly created temporary file. On systems where
this is possible, the temporary file is anonymous (i.e. it is unlinked
after creation, but held open). If the temporary file cannot be created or
opened, the <CODE>IO::File</CODE> object is destroyed. Otherwise, it is returned to the caller.
</DL>
<P>
<HR>
<H1><A NAME="METHODS">METHODS</A></H1>
<DL>
<DT><STRONG><A NAME="item_open">open( FILENAME [,MODE [,PERMS]] )</A></STRONG><P>
<DD>
[perlfunc:open|open] accepts one, two or three parameters. With one parameter, it is just a
front end for the built-in [perlfunc:open|open] function. With two parameters, the first parameter is a filename that may
include whitespace or other special characters, and the second parameter is
the open mode, optionally followed by a file permission value.
<P>
If <CODE>IO::File::open</CODE> receives a Perl mode string (``>'', ``+<'', etc.) or a
<FONT SIZE=-1>POSIX</FONT>
<CODE>fopen()</CODE> mode string (``w'', ``r+'', etc.), it uses the basic Perl
[perlfunc:open|open] operator.
<P>
If <CODE>IO::File::open</CODE> is given a numeric mode, it passes that mode and the optional permissions
value to the Perl <CODE>sysopen</CODE> operator. For convenience, <CODE>IO::File::import</CODE> tries to import the
<FONT SIZE=-1>O_XXX</FONT> constants from the Fcntl module. If dynamic
loading is not available, this may fail, but the rest of IO::File will
still work.
</DL>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
[perlman:perlfunc|perlfunc],
[perlman:perlop|perlop],
[perlman:IO::Handle|Handle]
[perlman:IO::Seekable|Seekable]
<P>
<HR>
<H1><A NAME="HISTORY">HISTORY</A></H1>
<P>
Derived from FileHandle.pm by Graham Barr <<EM>bodg@tiuk.ti.com</EM>>.
<HR>