if (-t STDIN) { # we're running from a shell, without input being # piped to us. } else { # ... } #### use IO::Handle; STDIN->blocking(0); # and try to read from it, like you would normally. my $line = ; if (defined $line) { # we have input, read succeeded } else { # no input at the moment. }