Temporarily redirecting STDERR
Curtis Poe
cp at onsitetech.com
Tue Apr 16 10:42:25 CDT 2002
----- Original Message -----
From: "Joe Oppegaard" <joe at joppegaard.com>
To: "PDX Perl List" <pdx-pm-list at pm.org>
Sent: Tuesday, April 16, 2002 12:52 AM
Subject: Temporarily redirecting STDERR
> I'm probably missing something obvious, but I can't seem to find the
> answer. How do you redirect stderr in scope, then have it return to its
> default once you leave that block?
This should do the trick, assuming I understood your question:
#!/usr/bin/perl -w
use strict;
{
local *STDERR;
open STDERR, "> err.txt" or die $!;
warn "This goes to the file";
}
warn "This doesn't";
--
Cheers,
Curtis Poe
Senior Programmer
ONSITE! Technology, Inc.
www.onsitetech.com
503-233-1418
Taking e-Business and Internet Technology To The Extreme!
TIMTOWTDI
More information about the Pdx-pm-list
mailing list