How do I detect if stdout is connected to a tty in Perl?

后端 未结 2 1808
攒了一身酷
攒了一身酷 2020-12-17 14:47

I\'m looking for the Perl equivalent to this Python code:

from sys import stdout
if stdout.isatty():
    print \"yes\"
else:
    print \"no\"
2条回答
  •  粉色の甜心
    2020-12-17 15:31

    Use IO::interactive if you require STDOUT to actually be connected to the terminal, and not just being redirected to /dev/null/ or whatever.

提交回复
热议问题