But you have two flags stating whether the filehandle was opened !
1) $oldhandle
2) $user_input
So,
> my $oldhandle=undef;
> if($user_input ne 'STDOUT') { #user specify output to a file
> open (OUT,">$temp.txt") or die "Can't open the file\n";
> $oldhandle = select OUT;
> }
> print "blah blah blah\n";
.. and :
if ( defined( $oldhandle )){
select ($oldhandle);
close OUT;
}
Well, it's not "checking the status of FileHandle" but solves your
problem in easier way, I think
- checking the status of FileHandle Charles Lu
- Re: checking the status of FileHandle Hasanuddin Tamir
- Re: checking the status of FileHandle Michael Fowler
- Re: checking the status of FileHandle Paul
- Evgeny Goldin (aka Genie)
