--- Charles Lu <[EMAIL PROTECTED]> wrote:
>
>Lets say I want my program to print to STDOUT unless the user
> specifies that the output goes to a file. Here is my code:
>
>
>
> my $oldhandle=undef;
> if($user_input ne 'STDOUT') { #user specify output to a
> file
> open (OUT,
> At this point I want to close my FileHandle (OUT) if it was open. My
> question is HOW do I check to see whether a filehandle(OUT) has been opened
> so I can explicitly close it with
The fileno operator is the typical way of determining if a filehandle is
connected to something.
Michael
--
he 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
On Tue, 12 Jun 2001, Charles Lu <[EMAIL PROTECTED]> wrote,
> 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";
>
> select ($ol
Lets say I want my program to print to STDOUT unless the user
specifies that the output goes to a file. Here is my code:
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 =