[OT] perl file handle question

Nicholas Clark nick at ccl4.org
Sat Mar 15 18:50:09 GMT 2008

It's relatively easy to write a function gives this sort of interface

my $fh = open_or_die($filename);

where the function will die with the filename and error message if the file
can't be opened.

However, what I'd then like to do is


and if the close fails, have the file *name* printed in the error message.

Is there a good clean way to have something that mostly behaves as a file
handle, but has the file name squirrelled away in it somehow?

Nicholas Clark

More information about the london.pm mailing list