Determine if perl script was launched from terminal or by gui on Windows

Viewed 74

I'm writing perl scripts on Windows, and need to determine if the a perl script was launched manually from a terminal (e.g., 'C:\Users\me\bin tst.pl') or via a gui (e.g., double-click on 'tst.pl'). In the former case, the script runs to completion, and any output generated is seen in the terminal window. In the latter case, the script is run, does its thing, may produce output (don't know...), and immediately is dismissed. I'd like to detect whether or not the script was run by the gui, so that I can have the option to have the script wait for user input. (E.g., 'print "$0: enter to exit... "; $_ = <STDIN>;)

Of course, I could always prompt the user for input, but that wouldn't work for scripts that got its input from a pipe. I guess I'd have the same issue on Linux for scripts that are launched from gui as well, but most all the (many...) scripts I've written are command-line driven. I'm new to running perl scripts on Windows, and am really curious as to how to properly do this.

Any suggestions? Thanx!

0 Answers
Related