in reply to Re^2: open3 but for n file descriptors
in thread open3 but for n file descriptors

Looking at the man page for open, it seems what I need is this:
open(my $err, '>', "foo.out"); open(STDERR, ">&", $err);
but in a generic version, so I can use other file descriptors than STDERR (fd2).