http://www.perlmonks.org?node_id=930967


in reply to Re^2: STDERR going to string
in thread STDERR going to string

because re-opening STDERR decouples perl's STDERR from the called C library's STDERR

It will probably work if you save/dup STDERR and restore it

open my $errsave, '>&', STDERR or do { print "couldn't dup STDERR: $!"; exit 2; }; open STDERR ... ... open STDERR, '>&', $errsave or do { print "couldn't restore/dup STDERR: $!"; exit 2; };