diff --git a/Changes b/Changes index debd9f3..188f38f 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,7 @@ Revision history for CGI-Info 0.80 Added documentroot() as a synonym to rootdir() For compatability with Apache + Allow "use lib CGI::Info::script_dir() . '../lib';" 0.79 Wed Jan 3 14:25:42 EST 2024 Better arg count checking diff --git a/lib/CGI/Info.pm b/lib/CGI/Info.pm index cda9fd6..307bbb1 100644 --- a/lib/CGI/Info.pm +++ b/lib/CGI/Info.pm @@ -222,11 +222,18 @@ Returns the file system directory containing the script. print 'HTML files are normally stored in ', $info->script_dir(), '/', File::Spec->updir(), "\n"; + # or + use lib CGI::Info::script_dir() . '../lib'; + =cut sub script_dir { my $self = shift; + if(!ref($self)) { + $self = __PACKAGE__->new(); + } + unless($self->{script_path}) { $self->_find_paths(); } diff --git a/t/script.t b/t/script.t index 1776151..3afb343 100644 --- a/t/script.t +++ b/t/script.t @@ -2,7 +2,7 @@ use strict; use warnings; -use Test::Most tests => 63; +use Test::Most tests => 64; use File::Spec; use Cwd; use Test::NoWarnings; @@ -22,6 +22,7 @@ PATHS: { ok($i->script_path() =~ /.+script\.t$/); ok($i->script_name() eq 'script.t'); ok($i->script_path() eq File::Spec->catfile($i->script_dir(), $i->script_name())); + ok($i->script_path() eq File::Spec->catfile(CGI::Info::script_dir(), $i->script_name())); # Check calling twice return path ok($i->script_name() eq 'script.t');