$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.
In reply to Re: IIS6 + Perl CGI: finding locations on disk
by ikegami
in thread IIS6 + Perl CGI: finding locations on disk
by rgcosma
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |