Can one use local to temporarily close STDERR?
- From: kj <socyl@xxxxxxxxxxxxxxxxx>
- Date: Mon, 12 Dec 2005 22:46:16 +0000 (UTC)
I would like to know whether it is possible to use localization to
*temporarily* close a global handle, e.g. STDERR. The following
doesn't work (all three messages appear on the screen):
warn "before closing\n";
{
local *STDERR;
# close STDERR;
warn "should be closed\n";
}
warn "still here\n";
If I explicitly close STDERR right after the local statement, then
only the first message gets printed.
Of course, I can achieve the desired effect (namely, selectively
silencing the second message) if I explicitly save and later restore
STDERR:
use Fatal qw( open close );
warn "before closing\n";
{
open my $save, '>&', *STDERR;
close STDERR;
warn "should be closed\n";
open STDERR, '>&', $save;
}
warn "still here\n";
....but I'm curious if there's a way to achieve the same effect without
doing this.
Thanks!
kj
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
.
- Follow-Ups:
- Re: Can one use local to temporarily close STDERR?
- From: Brian McCauley
- Re: Can one use local to temporarily close STDERR?
- From: attn.steven.kuo@xxxxxxxxx
- Re: Can one use local to temporarily close STDERR?
- Prev by Date: Re: What is the reason for Perl?
- Next by Date: Re: What is the reason for Perl?
- Previous by thread: Ignore keystrokes in Tk
- Next by thread: Re: Can one use local to temporarily close STDERR?
- Index(es):
Relevant Pages
|