note
twotone
<p>
Great summary of module basics!
</p>
<p>
Here's a little code I came up with to add my module location to @INC (in a cgi environment) by dynamically determining the document root for the script. It works on the remote apache server and when testing locally in windows. It might be of some interest:
</p>
<code>
BEGIN {
# get doc root from %ENV
# implicitly declare file root path if %ENV not fount
my $doc_root = $ENV{DOCUMENT_ROOT} ||
'C:/Users/User/Documents/website/sites/mysite';
# change \ to /
$doc_root =~ s/\\/\//g;
# add module folder location
$doc_root .= "/cgi-bin/cms/";
# add module location to @INC
push(@INC,$doc_root);
}
</code>
102347
102347