I'm looking for开发者_运维问答 the Perl equivalent to this Python code:
from sys import stdout
if stdout.isatty():
    print "yes"
else:
    print "no"
Use the -t filetest operator.
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.
Use IO::interactive if you require STDOUT to actually be connected to the terminal, and not just being redirected to /dev/null/ or whatever.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论