in reply to Telling if your script is running from web page or CLI

You can check whether *STDIN is a tty:

print -t *STDIN ? "Wow! A real person!\n" : "<p>I feel a distant presence . . .</p>";

After Compline,
Zaxo