IO::File::WithFilename - filehandles that know their origin
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
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.
IO::File
filename
File::Temp
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:
can
print $obj->filename, "\n" if eval { $obj->can('filename') };
Same as IO::File, i. e. O_XXX constants from the Fcntl module (if this module is available).
O_XXX
Fcntl
IO::File, File::Temp
Ivan Fomichev, <ifomichev@cpan.org>
Copyright (C) 2010 by Ivan Fomichev
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.
To install IO::File::WithFilename, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IO::File::WithFilename
CPAN shell
perl -MCPAN -e shell install IO::File::WithFilename
For more information on module installation, please visit the detailed CPAN module installation guide.