Is there a good way to detect if the Perl script is called from terminal/DOS or called from a web server.
I currently have this code:
sub cli {
# return 1 if called from browser, 0 if called from command line
if (defined $ENV{GATEWAY_INTERFACE} || exists $ENV{HTTP_HOST}){
return 0;
}
return 1;
}
but read that these ENV variables are not set by all servers.
The reason for this if the script run from terminal I will print text/plain formatted messages, if run from browser I will print HTML formatted messages.