For me, open STDERR, ">&", $error_fh
(along with open STDERR, ">&" . fileno($error_fh)
) does not return a true value. I think the >&
mode might be a pretty direct syntactic sugar for a dup
system call, which wouldn't work on a pseudo-filehandle like $error_fh
.
How about localizing STDERR
?
{
local *STDERR = *$error_fh;
say STDERR "something";
}
# STDERR restored