in reply to Can a script tell if it is being run from inside a script versus in an interactive terminal session?
You might try seeking on STDIN. If its connected to a redirected file, it should succeed; if its a pipe it will fail:
C:\test>perl -E"seek STDIN, 0,0 or die $!" <junk.txt C:\test>echo junk.txt | perl -E"seek STDIN, 0,0 or die $!" Invalid seek at -e line 1.
Put the seek in a die block and check for the error condition.
|
|---|