Re: Problem getting started - modperl

This is a discussion on Re: Problem getting started - modperl ; Please include the list on replies, so the archives are complete. Quoting "John M. Dlugosz" : > Adam Prime adam.prime-at-utoronto.ca |mod_perl mailing list| wrote: >> For the Apache2::Request problem you're running: >> >> use Apache2::Request; >> $req = Apache2::Request->new($r); >> ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Re: Problem getting started

  1. Re: Problem getting started

    Please include the list on replies, so the archives are complete.

    Quoting "John M. Dlugosz" :

    > Adam Prime adam.prime-at-utoronto.ca |mod_perl mailing list| wrote:
    >> For the Apache2::Request problem you're running:
    >>
    >> use Apache2::Request;
    >> $req = Apache2::Request->new($r);
    >> @foo = $req->param("foo");
    >> $bar = $req->args("bar");
    >>
    >> and getting a segfault on new?

    >
    > If I reduce it down to the first two lines only, I get the segfault.
    > If I reduce it to the first line only, I don't.
    >
    >
    >> Are you running this as a handler, or through one of the CGI
    >> emulation layers (ModPerl::PerlRun, or ModPerl::Registry for
    >> example). you do

    >
    > ModPerl::Registry.
    >
    > In my apache2.conf file:
    >
    > PerlModule ModPerl::Registry
    >
    >
    > SetHandler perl-script
    > PerlHandler ModPerl::Registry
    > Options +ExecCGI
    > PerlSendHeader On
    > Allow from all
    >

    >
    > Hmm, is there a way to find out whether these settings are applying to
    > the directory I think it is? /modperl/ should be applied to each
    > DocumentRoot, right?
    >


    correct.

    >> also have
    >>
    >> my $r = shift;
    >>
    >> somewhere above that (and ideally use strict; as well) right?

    >
    > No, just what it shows in the example.


    This is your problem. Apparently if you call Apache2::Request->new
    with an undefined object, it segfaults.

    i ran this:

    use Apache2::Request;
    my $req = Apache2::Request->new($r);
    print qq[Content-type: text/html\n\n];
    print q[hi];

    through registry, and saw

    [Sat Jul 12 22:58:58 2008] [notice] child pid 5703 exit signal
    Segmentation fault (11)

    If you change that to

    use Apache2::Request;
    my $r = shift;
    my $req = Apache2::Request->new($r);
    print qq[Content-type: text/html\n\n];
    print q[hi];

    it should work. Unfortunately, it looks like the documentation for
    ModPerl::Registry is kind of lacking on perl.apache.org, but what is
    there is at
    http://perl.apache.org/docs/2.0/api/.../Registry.html

    Adam


  2. Re: Problem getting started


    > This is your problem. Apparently if you call Apache2::Request->new
    > with an undefined object, it segfaults.
    >
    > i ran this:
    >
    > use Apache2::Request;
    > my $req = Apache2::Request->new($r);
    > print qq[Content-type: text/html\n\n];
    > print q[hi];
    >
    > through registry, and saw
    >
    > [Sat Jul 12 22:58:58 2008] [notice] child pid 5703 exit signal
    > Segmentation fault (11)
    >
    > If you change that to
    >
    > use Apache2::Request;
    > my $r = shift;
    > my $req = Apache2::Request->new($r);
    > print qq[Content-type: text/html\n\n];
    > print q[hi];
    >
    > it should work. Unfortunately, it looks like the documentation for
    > ModPerl::Registry is kind of lacking on perl.apache.org, but what is
    > there is at
    > http://perl.apache.org/docs/2.0/api/.../Registry.html
    >
    > Adam
    >

    OK, when I defined $r as you did, it worked. For documentation, I was
    looking at here:


    I see you are just printing to standard output, like a CGI script. In
    the book, it used

    $r->send_http_header('text/plain');
    $r->print("mod_perl rules!\n");

    but there are no such methods on $r here in 2.0.

    What, prey tell, is the equivalent object?

    Is there =any= way to get started, like a simple (but working!) program
    I could look at?

    --John


  3. Re: Problem getting started


    Hi John,


    John M. Dlugosz wrote:
    > OK, when I defined $r as you did, it worked. For documentation, I was
    > looking at here:
    >
    >
    >
    > I see you are just printing to standard output, like a CGI script. In
    > the book, it used
    >
    > $r->send_http_header('text/plain');
    > $r->print("mod_perl rules!\n");
    >
    > but there are no such methods on $r here in 2.0.
    >
    > What, prey tell, is the equivalent object?
    > Is there =any= way to get started, like a simple (but working!)
    > program I could look at?



    When I was starting with modperl2, I had similar problems to you. I'm
    more of a book-person, and many of the books (such as the O'Reilly ones)
    have not been re-released for modperl2. While there is a lot of
    information on the web, it isn't as easy sifting through it all.

    As for your question, the $r object is (I believe :-) ) the RequestRec
    object:

    http://perl.apache.org/docs/2.0/api/...equestRec.html

    and instead of send_http_header, you would use content_type. As
    mentioned here which describes porting mod_perl 1.0 to mod_perl 2.0:

    http://perl.apache.org/docs/2.0/user...d_http_header_

    You may need to use these two documents (at least) in conjunction with
    the book you are reading to make any sense of it. Hope this helps!

    Ray


  4. Re: Problem getting started

    On Sun, Jul 13, 2008 at 1:21 AM, John M. Dlugosz
    wrote:
    > OK, when I defined $r as you did, it worked. For documentation, I was
    > looking at here:
    >


    Hi John,

    That SYNOPSIS is more like a set of possible calls to
    Apache2::Request, not a literal series of lines. You do need to get
    $r (an Apache2::RequestRec object) first.

    > I see you are just printing to standard output, like a CGI script.


    When using ModPerl::Registry, you can just print to STDOUT.

    > In the book, it used
    >
    > $r->send_http_header('text/plain');
    > $r->print("mod_perl rules!\n");
    >
    > but there are no such methods on $r here in 2.0.
    >
    > What, prey tell, is the equivalent object?


    That's Apache2::RequestRec.

    > Is there =any= way to get started, like a simple (but working!) program I
    > could look at?


    There are two places you should look for MP2 docs. The first is the
    mod_perl site, which has all the API docs and many examples. If you
    want a book, the only one you should use for MP2 at this point is
    "mod_perl2 User's Guide": http://modperl2book.org/

    - Perrin


+ Reply to Thread