On Wed, 29 Aug 2001, Billy Patton wrote:
> #!/usr/local/bin/perl5.005 -w
> use strict;
>
> &a;
> print "this goes to a\n";
> close STDOUT;
> close TEE;
> &b;
> print "this goes to b\n";
> close STDOUT;
> close TEE;
> # this prints only "this goes to a" to stdout
> # all other lines get printed to file, twice.
>
> # if I remove the close STDOUT it hangs at the first close TEE
>
> # if I remove all close statements and let the systems
> # close TEE automatically because it is being used again
> # I get a lockup on &b. I'm guessing it is where the system
> # is trying to close the already open TEE
>
> #So how do I open STDOUT after it has been closed?
> # do I get the tty and open it to that?
> # is there some other way to reopen STDOUT?
Don't close or reopen STDOUT without duping the filehandle first
[See: perldoc -f open] if you want it back later.
Have you tried using IO::Tee?
--
Vivek