How can I tell if STDIN is connected to a terminal in Perl?
if (-t *STDIN) {
# stdin is connected
} else {
# stdin is not connected
}
I usually use this in conjunction with -t *STDOUT
, to find out if I'm running from an interactive shell, or from cron, to enable more output.