You could check for the existence of an environmental variable set by web servers, such as $ENV{SCRIPT_NAME}. This may or may not work well with persistent technologies such as mod_perl, but scripts running there don't seem too likely to run in "offline" mode.