IO::File::WithFilename(3pm)

IO::File::WithFilename3pm

Filehandles that know their origin

Usage

    use IO::File::WithFilename;
    my $fh = IO::File::WithFilename->new('../movies/kin-dza-dza.ogg', O_RDONLY);
    print $fh->filename, "\n";
    print "$fh\n"; # same as above

Overview

This module does everything that "IO::File" does, but implements "filename" method, that "File::Temp" objects have. It lets you write the code that is ignorant of what classes of objects it works with.

If you want to check if it is safe to call "filename" method, you are recommended to call "can" method rather than to check an object's inheritance:

    print $obj->filename, "\n" if eval { $obj->can('filename') };

Export

Same as "IO::File", i. e. "O_XXX" constants from the "Fcntl" module (if this module is available).

Releases

Unchanged in 2 releases since Debian 12 (Bookworm).

  1. 12–13

Author

Ivan Fomichev, <[email protected]>

From libio-file-withfilename-perl 0.01-2 in Debian 13 (Trixie). Parsed by carta from the page's man source.