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

Hello Monks. I've been banging my head against my desk for hours trying to figure out how to use the timeout method from Apache2::ServerRec. The synopsis for this says you can do:
use Apache2::ServerRec (); $timeout = $s->timeout();
Where does $s come from? I've looked into handlers, thinking that was the solution, but I can't get anything to work. Aaaahh! Any help would really be appreciated. Thanks!

Update: I thought you might want to know what my latest attempt was. The perl I have is:
#!/opt/local/bin/perl package MyApache2::Timeout; use strict; use warnings; use CGI::Carp qw{fatalsToBrowser}; use Apache2::ServerRec(); use Apache2::Const -compile => qw{OK}; sub handler { my $r = shift; $r->content_type('text/plain'); my $timeout = $r->timeout(); return Apache2::Const::OK; } 1;
And in httpd.conf:
PerlModule MyApache2::Timeout <Location /timeout> SetHandler modperl PerlResponseHandler MyApache2::Timeout </Location>
When I go to http://localhost/timeout, I get an internal server error (no details like I would expect from using CGI::Carp). I know that MyApache2::Timeout is being loaded because if I comment out the my $timeout = $r->timeout(); line and restart Apache, I get no error.

Replies are listed 'Best First'.
Re: Apache2::ServerRec Cluelessness
by redhotpenguin (Deacon) on Jan 26, 2008 at 18:47 UTC

    You also need use Apache2::RequestRec (), then grab $s by my $s = $r->server;.

      You are my hero! There must be some documentation that I missed... could you point me to where I should go so that I don't have to ask stupid questions like that again? Thank you so much!!
        Yeah, just make your way over to http://perl.apache.org/ :)