in reply to Re: Capturing warnings from Time::Piece
in thread Capturing warnings from Time::Piece
You may want to open another filehandle to STDERR before closing STDERR so that you can redirect STDERR to the original console again later.The same effect can be achieved in a simpler way:
Due to the local statement, when control leaves the surrounding block, STDERR will be restored to the old file handle which is connected to the console.my $err; local *STDERR; open STDERR, '>', \$err; use Time::Piece; $time = Time::Piece->strptime('2005-02-24 23:000', "%Y-%m-%d %H:%S");
|
|---|