in reply to Re^2: Function that accepts either a file name or a handle
in thread Function that accepts either a file name or a handle

eval{<$arg>} was my third thought. But testing reminded me that <...> doesn't give you any reasonable way to distinguish "end of file" from "error reading".

I don't understand how eval could be employed since the following program does not die when you read from <$fh>:

my $fh = 'f.tmp'; my $s = <$fh>; print "i am here: s='$s'\n";

That is, there is nothing to catch.

Replies are listed 'Best First'.
Re^4: Function that accepts either a file name or a handle ("but")
by tye (Sage) on Apr 21, 2004 at 18:34 UTC
    That is, there is nothing to catch.

    Yes. That was why the second sentence started with "But".

    - tye