TTY testing 

if(-t STDOUT) {
    say "STDOUT is a TTY";
}
else {
    say "STDOUT is not a TTY";
}