in reply to Re: Getting started with mod_perl
in thread Getting started with mod_perl

The code I tried was the 4 lines from the Synopses: http://search.cpan.org/~joesuf/libapreq2-2.08/glue/perl/lib/Apache2/Request.pm#SYNOPSIS.

It turn out that it segfaults if you pass new a parameter value of undef. Clearly, that is not a working example, and there is no cross-reference or information on that page about where that value was supposed to have come from in the first place. Sure, I can look up Apache2::RequestRec but that tells me what methods are available, and continues to show a global $r that is assumed to simply exist without showing how you are supposed to declare and obtain it.

Replies are listed 'Best First'.
Re^3: Getting started with mod_perl
by clinton (Priest) on Jul 14, 2008 at 08:38 UTC

    Ah, yes. That's a failure of assumption by the doc authors :), and really Apache2::Request should throw a proper error message instead of segfaulting in that situation. I'd raise a bug against that.

    The reason I say assumption is that, for mod_perl programmers, $r is The One True Way of communicating with mod_perl, and so they have assumed that you know how to get hold of it. For somebody who is new to mod_perl, this is obviously not the case.

    From the emails on the mod_perl mailing list, I assume that you have now sorted the issue out, but for clarification here, to get $r, which is an Apache2::RequestRec object, you would do the following:

    mod_perl 1 had a lot of good docs, a lot of which were written by Stas Bekman while Ticketmaster paid him to work on mod_perl. mod_perl 2 has a lot of good code, but the docs have been written by people who are intimately familiar with the internals. So everything is there, but not as clearly laid out as it could be. Also, everybody has full time jobs... you know how it goes.

    However, they are very receptive to doc (and other) patches, so if you see ways to improve what we have already, feel encouraged to send patches through - they will be warmly welcomed.

    Clint