in reply to
if (STDERR == STDOUT)
I second ikegami's advice - you should handle this with a commandline option instead of trying to detect whether the file descriptor for STDOUT and STDERR are writing to the same stream. From perl's perspective they are separate entities, as can be seen with fileno.
As a last resort you could query the operating system with tools like lsof or the proc filesystem to find out where that filedescriptor is writing... but that would be somewhat bad mojo and should be avoided.