in reply to dup2 exact file descriptor

perldoc perlopentut has examples of reopening STD(OUT|ERR). You could also look at POSIX for its dup2().