--- 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
--
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;
> }
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