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

Perrin Harkins <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CAC0_be27A4M-nXj2Y8Ob3tJsEKgahahs81fbRpeXUHLLJ=hhBA@mail.gmail.com>
Hi Worik,

Your ErrorLog question isn't really a mod_perl issue, but I'd suggest
you check for warnings at startup.  You may not have APACHE_LOG_DIR
defined, etc.

I don't use Apache2::Directive, so I can't vouch for it.  I prefer
simpler things like PerlSetVar.  There is an automated test for this
though:
http://cpansearch.perl.org/src/PHRED/mod_perl-2.0.8/t/response/TestApache/conftree.pm

I'd suggest doing some more basic debugging, e.g.

  use Data::Dumper;
  print Dumper $tree->as_hash;

- Perrin

On Tue, May 13, 2014 at 8:24 PM, Worik Stanton <[email protected]> wrote:
> 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)
>
>
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.