in reply to Script running online?

You can try this:
if (-t STDIN) { print 'running in terminal'; } else { print 'running in batch'; }
The '-t' filetestoperator checks if the filehandle is a tty.