How do I detect if stdout is connected to a tty in Perl?
Question: I'm looking for the Perl equivalent to this Python code:

    
    
    from sys import stdout
    if stdout.isatty():
        print "yes"
    else:
        print "no"
    


Answer: Use the [-t filetest operator](http://perldoc.perl.org/functions/-X.html).

    
    
    print -t STDOUT ? "Yes\n" : "No\n"
    

Note that in Perl, STDOUT can be tied (essentially an overcomplicated
overloaded object) so output to STDOUT may still reach a TTY even if its not
directly attached to one.

