[Chapter 8] 8.83 FileHandle
Author: Ellen Siever, Stephen Spainhour & Nathan Patwardhan
Date: 1999-07-02T01:47:39Z

#

| Chapter 8 Standard Modules |

## 8.83 FileHandle

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

- new
- new_from_fd
- fdopen
- getpos
- open
- setpos
- setvbuf

The following additional FileHandle methods act as front-ends for the corresponding built-in Perl functions (see the O'Reilly book Programming Perl or the perlfunc manpage for more detail):

`clearerr` | `getc`
`close` | `gets`
`eof` | `seek`
`fileno` | `tell`

The next group of FileHandle methods correspond to Perl special variables (see Programming Perl or the perlvar manpage):

`autoflush` | `format_page_number`
`format_formfeed` | `format_top_name`
`format_line_break_characters` | `input_line_number`
`format_lines_left` | `input_record_separator`
`format_lines_per_page` | `output_field_separator`
`format_name` | `output_record_separator`

Finally, the following methods are useful:

$fh`->print`

  See Perl's built-in `print` function.

$fh`->printf`

  See Perl's built-in `printf` function.

$fh`->getline`

  Works like Perl's <FILEHANDLE> construct, except that it can be safely called in an array context (but it still returns just one line).

$fh`->getlines`

  Works like Perl's <FILEHANDLE> construct when called in an array context to read all remaining lines in a file.

8.82 FileCache |  | 8.84 FindBin