in reply to What kind of file is my stdout ?

You can use the -t switch on STDIN and STDOUT to test whether it's a file or an tty
sub check { return(-t STDOUT); }
Should return false or true.