Trouble with mod_perl API: E.g., Apache2::Directive::conftree()

Worik Stanton <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
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
       [email protected] 021-1680650, (03) 4821804
                          Aotearoa (New Zealand)
signature.asc (application/pgp-signature, 538 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTcrfPAAoJEDgltBsVWtVc5ZgH/2Y5HoXhbwPEECucwPBGqHUl
mrJ04iW2DmfcKx8m+JXIqHQOPSiKvIgZDWiChILx+WgBrlAlJ/mp4VTgrfk/5wOH
vVIpIpE+j9wpNXd/p2QUgXfEV0z1vZS/KhGwko45LsTKER9IQASUSJNllHMGo7Xe
QETy+ThSZj0KvJb0nCiX4dFJcFO/AMLPB0enbesPWIn63rdsVuIeDPnrz+sO5qut
CxFVSKiZ44OCMe91NaEFvMZsCsBiYbw1G4gyGbG7CB3/xbEnZ08Eu3qyxbq07KY8
rW1qjE5aCM7Lnz8/0Um9LensRN7jxygxGpPepiRo6Xcf0aI1ByMhXeG7BMYcvNI=
=IcmY
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.