in reply to #exec and $ENV{'PATH_INFO'}

PATH_INFO does NOT return the URL for the called page, only any extra path data that was appended after the URL for the called page. Example (on Apache):

You have a page on url http://localhost/test.shtml that includes (with #exec cgi) /script.cgi and you call this with http://localhost/test.shtml/extra/path?param=1 you get the following:

REQUEST_URI = /test.shtml/extra/path?param=1 PATH_INFO = /extra/path QUERY_STRING = param=1 SCRIPT_NAME = /script.cgi DOCUMENT_URI = /test.shtml/extra/path
Unfortunately (on Apache), there seems to be no environment variable that shows only the URI of the called shtml page (should be /test.shtml here) if the request contains extra path_info.

Your best bet would probably be to remove $ENV{PATHINFO} from $ENV{DOCUMENT_URI}.

Please note that SSI support and implementation varies betweeen different (versions of) webservers, so you probably should test all this yourself by including a test script in a shtml page like this:

#!/usr/bin/perl print "Content-type: text/plain\n\n"; for (sort keys %ENV) { print "$_ : $ENV{$_}\n"; }
Also note that using CGI.pm may change the value of certain environment variables. YMMV.
-- Joost downtime n. The period during which a system is error-free and immune from user input.