FileHandle

FileHandle

NAME

FileHandle - supply object methods for filehandles

SYNOPSIS

use FileHandle;

$fh = FileHandle->new;
if ($fh->open("< file")) {
    print <$fh>;
    $fh->close;
}

$fh = FileHandle->new("> FOO");
if (defined $fh) {
    print $fh "bar\n";
    $fh->close;
}

$fh = FileHandle->new("file", "r");
if (defined $fh) {
    print <$fh>;
    undef $fh;       # automatically closes the file
}

$fh = FileHandle->new("file", O_WRONLY|O_APPEND);
if (defined $fh) {
    print $fh "corge\n";
    undef $fh;       # automatically closes the file
}

$pos = $fh->getpos;
$fh->setpos($pos);

$fh->setvbuf($buffer_var, _IOLBF, 1024);

($readfh, $writefh) = File