in reply to Re: Re: Restoring STDOUT and STDERR after having redirected them to files
in thread Restoring STDOUT and STDERR after having redirected them to files
So, using fileno() on your globs, you can dup your filehandles like in the open example, except with the numbers instead of the names! An updated snippet from your code:If you specify '<&=N', where N is a number, then Perl will do an equivalent of C's fdopen() of that file descriptor; this is more parsimonious of file descriptors. For example: open(FILEHANDLE, "<&=$fd")
# restore STDOUT my $fd = fileno($this->{'_stdout'}); open(STDOUT, ">&=$fd"); print STDOUT "STDOUT restored\n";
|
|---|