Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks, I'm trying to check whether a filehandle from
open is valid after the call. If the filehandle is valid,
I want to use it to print with, if it is not I want
to do something else. For some reason, the below code
segment doesn't work. It always goes to the else
part of the code.
I know i can do this:open($test, "<test.txt"); if (!$test) { #do something } else { #use $test to print something }
but i really need to check for a valid filehandle after the open is complete. Is there a way to do this? thanks, Michaelopen($test, "<test.txt") || die("$!\n");
Back to
Seekers of Perl Wisdom