in reply to if (STDERR == STDOUT)

If all you have is the end of a pipe - it is hard to say what is on the other side. You could try and fish around in /proc/$$/fd . You could look at the 1 and 2 files to see if they are to the same thing.
paul@paul-laptop:~/$ perl -e 'print "Pid: $$\n"; print `ls -l /proc/$$ +/fd`' Pid: 391 total 8 lrwx------ 1 paul paul 64 2007-03-06 09:34 0 -> /dev/pts/1 lrwx------ 1 paul paul 64 2007-03-06 09:34 1 -> /dev/pts/1 lrwx------ 1 paul paul 64 2007-03-06 09:34 2 -> /dev/pts/1 lr-x------ 1 paul paul 64 2007-03-06 09:34 3 -> pipe:[162460] l-wx------ 1 paul paul 64 2007-03-06 09:34 4 -> pipe:[162460] lr-x------ 1 paul paul 64 2007-03-06 09:34 5 -> pipe:[162461] lr-x------ 1 paul paul 64 2007-03-06 09:34 6 -> inotify l-wx------ 1 paul paul 64 2007-03-06 09:34 7 -> pipe:[162461] paul@paul-laptop:~/$ perl -e 'print "Pid: $$\n"; print `ls -l /proc/$$ +/fd`' 2>&1 Pid: 393 total 5 lrwx------ 1 paul paul 64 2007-03-06 09:34 0 -> /dev/pts/1 lrwx------ 1 paul paul 64 2007-03-06 09:34 1 -> /dev/pts/1 lrwx------ 1 paul paul 64 2007-03-06 09:34 2 -> /dev/pts/1 lr-x------ 1 paul paul 64 2007-03-06 09:34 3 -> pipe:[162483] lr-x------ 1 paul paul 64 2007-03-06 09:34 6 -> inotify paul@paul-laptop:~/$ perl -e 'print "Pid: $$\n"; print `ls -l /proc/$$ +/fd`' 2>/dev/null Pid: 395 total 8 lrwx------ 1 paul paul 64 2007-03-06 09:34 0 -> /dev/pts/1 lrwx------ 1 paul paul 64 2007-03-06 09:34 1 -> /dev/pts/1 l-wx------ 1 paul paul 64 2007-03-06 09:34 2 -> /dev/null lr-x------ 1 paul paul 64 2007-03-06 09:34 3 -> pipe:[162501] l-wx------ 1 paul paul 64 2007-03-06 09:34 4 -> pipe:[162501] lr-x------ 1 paul paul 64 2007-03-06 09:34 5 -> pipe:[162502] lr-x------ 1 paul paul 64 2007-03-06 09:34 6 -> inotify l-wx------ 1 paul paul 64 2007-03-06 09:34 7 -> pipe:[162502]


my @a=qw(random brilliant braindead); print $a[rand(@a)];