CGI-Scriptpaths
view release on metacpan or search on metacpan
lib/CGI/Scriptpaths.pm view on Meta::CPAN
This uses some tricks to find those things even if environment variables are not set.
=head2 WHY
Even outside a cgi environment, a script usinng this can find its way around.
For example in this fs hierarchy:
/home/user/
/home/user/public_html
/home/user/cgi-bin
/home/user/cgi-bin/a/script.cgi
Even without DOCUMENT_ROOT set, script.cgi knows that document root is /home/user/public_html.
Valid dir names are also htdocs and html.
So, in this following fs hierarchy, it will also know to find document root:
/home/user/
/home/user/html
/home/user/html/script.cgi
/home/user/cgi-bin
The way it works, is it steps backwards and looks for these directories.
=head1 SUBS
None of these are exported by default.
=head2 script_abs_path()
returns script's absolute location
on failure warns and returns undef
=head2 script_abs_loc()
returns script's abs path to the directory it resides in
on failure warns and returns undef
=head2 script_filename()
returns the script's filename
=head2 script_filename_only()
returns the script's filename without ext (if there was one)
=head2 script_ext()
returns script's ext (without dot) if there is one
returns undef if none
=head2 abs_cgibin()
tries to find path to cgi-bin
may warn and return undef
=head2 DOCUMENT_ROOT()
assumes this is a website and returns document root
if $ENV{DOCUMENT_ROOT} is not set, it tries to test and guess for it
on failure returns undef
=head2 script_rel_path()
returns script's relative path to DOCUMENT_ROOT()
warns and returns undef on failure
=head2 script_rel_loc()
returns the path of the directory the script resides in, relative to DOCUMENT_ROOT()
warns and returns undef on failure
=head2 script_is_in_DOCUMENT_ROOT()
returns boolean
returns undef if DOCUMENT_ROOT() can't return value.
=head2 script_is_in_cgibin()
returns boolean
returns undef if abs_cgibin() can't return value.
=head1 DEBUG
$CGI::Scriptpaths::DEBUG = 1;
=head1 BUGS
Please contact AUTHOR.
=head1 AUTHOR
Leo Charre leocharre at cpan dot org
=head1 SEE ALSO
Cwd::Ext
Cwd
=cut
( run in 0.495 second using v1.01-cache-2.11-cpan-e1769b4cff6 )