in reply to Re: Filehandle open?
in thread Filehandle open?

And since we're using the pragma, we can also be more specific about which warnings we don't want. Then we can lose the prototype for errorchecking too (which it only does shoddily anyway). And lastly, undef is a one-element list and evaluates as true in list context, so we just let Perl decide what value the boolean expression should return.
sub is_opened { no warnings qw(closed unopened); return tell $_[0] != -1; }

Update: Oops. s/==/!=/ - otherwise the truth value is reversed of course. Thanks, blakem.

Update 2: and of course, check perldoc perllexwarn about the detailed warning names you can use to enable/disable specifically.

Update 3 (the neverending story): fruiture informs me that you have to disable not only the closed category, but unopened as well. Code updated accordingly.

Makeshifts last the longest.