in reply to URL $ENV variables

Is this is a standard CGI? If so, have a look at $ENV{SCRIPT_FILENAME} and $ENV{SCRIPT_NAME}. SCRIPT_FILENAME gives the absolute path to the running script and SCRIPT_NAME gives the virtual path to the script, both sans query string.

If you want to see all environment variables available to your script, create a script that loops through all the keys of %ENV and prints all key/value pairs.