I am having a lot of trouble with mod_perl APIs. The short of it is that when I say:
use Apache2::Directive (); my $tree = Apache2::Directive::conftree(); my $documentroot = $tree->lookup('DocumentRoot'); warn "\$documentroot '$documentroot'"; I get: [Wed May 14 12:13:43 2014] -e: Use of uninitialized value $documentroot in concatenation (.) or string at /home/worik/Worik.org/cgi/track line 11. [Wed May 14 12:13:43 2014] -e: $documentroot '' at /home/worik/Worik.org/cgi/track line 11. in the logs. I copied the code from https://perl.apache.org/docs/2.0/api/Apache2/Directive.html The longer of it is: In the past (15 years ago) I installed mod_perl and forgot about it. I set up my perl cgi script handler to be mod_perl in httpd.conf, and the only real effect it had on my development cycle was I often had to restart Apache to get it to notice I had changed a script. These days I am more ambitious and am returning to Web programming after a long break. I expect mod_perl to still be useful to cut the overhead of starting Perl. I expect a high throughput this time around, each request will be worth very little to me so I want lots and lots of requests. SO far so good. I have set up my server: ## mod_perl2 configuration Alias /cgi/ /home/worik/Worik.org/cgi/ PerlModule ModPerl::Registry ## PerlModule Apache::Registry PerlSwitches -T ErrorLog ${APACHE_LOG_DIR}/Worik.error.log <Location /cgi/> SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI Order allow,deny Allow from all </Location> Now I would like to use the API. In the first instance I want to find what the directory is I am running in. So I want to say: use Apache2::Directive (); my $tree = Apache2::Directive::conftree(); my $pwd = $tree->lookup("cgi"); But that fails just like the example at the start of this email. Also my errors are coming out in the wrong log. When I say warn("foo") I expect it to come out in the file specified by the ErrorLog directive but it comes as: [Wed May 14 12:22:53 2014] -e: foo at /home/worik/Worik.org/cgi/track line 12. in /var/log/apache2/error.log which is not what I specified. I am at a loss. Is the documentation up to date? Is mod_perl still being used out there? cheers Worik -- The only true evil is turning people into things.... Granny Weatherwax worik.stan...@gmail.com 021-1680650, (03) 4821804 Aotearoa (New Zealand)
signature.asc
Description: OpenPGP digital signature