ryddler has asked for the wisdom of the Perl Monks concerning the following question:

In reviewing some software I ran across the requirement in one software package for Apache::Request, so I did the good ol' cpan install for libapreq (or rather attempted the cpan install) without any success (on win32).

Not to be dissuaded so easily I downloaded the package from cpan and did a manual install. Nothing flashed by onscreen during 'nmake'. There appeared to be no tests defined, so 'nmake install' showed activity of copying .pm files to the appropriate locations, and navigating to those directories showed modules were in fact located where they should be located.

Ok, wonderful, all looks good, so I add the 'include' line into httpd.conf and attempt to stop and start apache, but apache squawks "Can't locate loadable object for module Apache::Request in @INC ... "

Further investigation reveals no binaries in the site/lib/auto/apache/request directory, although there is indeed c code in the install package, as well as code in Makefile.pl to distinguish between win32 and other os types for creating the makefile. Maybe a win32 problem? So next I tried it on a RH 7.1 box with a fresh build of perl 5.6.1 on it. Same process, CPAN first this time with a successful build and compiler instructions racing by on the screen. I verified that there was indeed a file named "Request.so" in the auto subdir, and ran this test script:

#! /usr/bin/perl use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); use Apache::Request; use Data::Dumper; print header; print "hello world<br>"; my $r; eval {$r = Apache::Request->new();}; print "$@ <br>"; print Dumper($r); map { print "$_<br>" } @INC;

Which spits out the following:

hello world
Can't locate object method "new" via package "Apache::Request"
(perhaps you forgot to load "Apache::Request"?)
at /usr/local/apache/cgi-bin/testapache.pl line 13.
$VAR1 = undef; 
/usr/local/lib/perl5/5.6.1/i586-linux
/usr/local/lib/perl5/5.6.1
/usr/local/lib/perl5/site_perl/5.6.1/i586-linux
/usr/local/lib/perl5/site_perl/5.6.1
/usr/local/lib/perl5/site_perl

So my questions are:



ryddler

Replies are listed 'Best First'.
Re: Apache::Request, myth or reality?
by echo (Pilgrim) on Sep 17, 2001 at 20:25 UTC

    I use libapreq under Unix. I've installed it using CPAN.pm, it is libapreq 0.31. Maybe it requires the script to run under mod_perl? I'm not sure, since all my scripts run under mod_perl, but the documentation seems to imply it, here's what it says for method new():

    my $apr = Apache::Request->new($r);

    I understand this to imply you need an Apache request object ($r) which you will only have available under mod_perl.

    For further information you can check out the libapreq webpage which has links to mailing lists which might provide some help.

Re: Apache::Request, myth or reality?
by perrin (Chancellor) on Sep 17, 2001 at 20:48 UTC
    You must have mod_perl installed to use Apache::Request. It is an extension of mod_perl. Also, you're not following the documentation for the new() method correctly. You're supposed to call it with a request_rec object from mod_perl: my $apr = Apache::Request->new($r);
      I do have mod_perl installed. I'm thinking my problem has to do with libapreq not installing properly because there doesn't seem to be a Request.dll in the site/lib/auto/Apache/Request folder.

      ryddler
        I've never tried using libapreq on NT. You should probably look at the mod_perl mailing list. You can find some discussion about libapreq on NT here. There are pre-built binaries available as well.