NAME

Klonk::Handle - IO::Handle subclass that remembers filenames

SYNOPSIS

use Klonk::Handle ();
my $fh = Klonk::Handle->openr($filename)
    or die "Can't open $filename: $!";
my $line = readline $fh;
say "I read a line from ", $fh->path;

DESCRIPTION

This class provides one constructor and one instance method. All other methods are inherited from IO::Handle.

Objects of this class are meant to be used as PSGI response bodies. The provided path method may allow some servers to serve the file directly and more efficiently than repeatedly filling a buffer by calling methods on an object.

Constructor

Klonk::Handle->openr($filename)

Opens $filename for reading in binary mode (:raw) and returns a handle object. The object is usable as a filehandle with built-in functions like readline or seek; it also supports the methods of IO::Handle.

Methods

$fh->path

Returns the name of the file that $fh refers to. $fh must have been constructed by a call to "Klonk::Handle->openr($filename)".

SEE ALSO

IO::Handle