in reply to IIS6 + Perl CGI: finding locations on disk
$cgi->script_name() or $ENV{SCRIPT_NAME} for the url of the script relative to the root url of the server.
Until you do a chdir, rel2abs($0) gives the absolute file system path to the script.
My server provides the document root in $ENV{DOCUMENT_ROOT}.
Combined with File::Spec and CGI, you have all you need.
Update: Example:
use File::Basename qw( dirname ); use File::Spec::Functions qw( rel2abs ); my $script_path = rel2abs($0); my $script_dir = dirname($script_path); my $script_url = $ENV{SCRIPT_NAME}; my $doc_root = $ENV{DOCUMENT_ROOT}; my $redirect_to = URI->new_abs('bar.cgi', $script_url); # /dir/bar.cgi
I can't come up with any reason to use $script_path or $doc_root.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: IIS6 + Perl CGI: finding locations on disk
by rgcosma (Beadle) on Sep 13, 2008 at 16:48 UTC | |
by ikegami (Patriarch) on Sep 13, 2008 at 16:55 UTC | |
by rgcosma (Beadle) on Sep 13, 2008 at 17:36 UTC | |
by Anonymous Monk on Sep 14, 2008 at 05:31 UTC |