use strict; if ( -t STDIN ) { print "This is what you're supposed to do ...\n"; exit; } # or use POSIX qw(isatty); if ( isatty(\*STDIN) ) { print "This is what you're supposed to do ...\n"; exit; } while () { print STDOUT "Add something to STDOUT".$_; }