home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

Book HomeJava and XSLTSearch this book

8.112. FileHandle

Provides object methods for working with filehandles. Provides the following methods.


$fh = new FileHandle [filename[, mode]]

Constructor. Creates a FileHandle, which is a reference to a newly created symbol. The optional parameters, filename and mode, are passed to open. The FileHandle object is returned if the open succeeds; otherwise, it is destroyed.


$fh = new_from_fd FileHandle fd, mode

Constructor. Creates a FileHandle, but it takes the file descriptor, fd, instead of filename as a parameter, along with mode; the parameters are required.


$fh->fdopen fdname [openmode]

Like open, except that its first parameter is not a filename but a filehandle name, a FileHandle object, or a file descriptor number.


$pos = $fh->getpos

If the C functions fgetpos(3) and fsetpos(3) are available, getpos returns the current position, $pos, of the FileHandle.


$fh->open filename [openmode]

Takes filename and, optionally, the open mode, and opens a file. If the mode is present, it can be in Perl form (e.g., >, +<) or in POSIX form (e.g., w, r+).


$fh->setpos pos

Uses the value (pos) returned by getpos to restore a previous position of the FileHandle.

Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.