This is more of a "rubber duck" debug than anything, but I've reached a point where I think I need an external set of eyes.

I'm tasked with migrating a mod_perl app to mod_perl 2. For the last couple of weeks, it's been reasonable (run code, get error, convert code call, check it works, move on...). But now I've hit a wall and I'm not sure how to proceed.

The app uses chained PerlResponseHandlers (was PerlHander in mp1) to process plain CGI scripts and thern to wrap them in a presentation layer (this is a really old school framework, and I'm not meant to be improving it, just get it to work).

The apache config for the section I'm on is like this:

<Directory /path/to/mp> SetHandler perl-script PerlAccessHandler APP::Phase::Authen PerlResponseHandler APP::Page ModPerl::Registry Options ExecCGI </Directory>

The APP::Page module inherits from Apache::Forward, a local module based on code "Taken from Stein & MacEachern's book" (which I don't have a copy of with me, alas :) Here's the handler code from the module:

sub handler ($$) { my ($class, $r) = @_; my $next = tied *STDOUT || return SERVER_ERROR; tie *STDOUT, $class, $r, $next or return SERVER_ERROR; $r->register_cleanup( sub { no warnings 'untie'; untie *STDOUT; }); OK; }

There's also TIEHANDLE, PRINT and forward methods in the class. Two things I notice when running this under mod_perl2:

I'm not 100% sure how the chained handlers work. I assume from right to left in the Apache config. But what about the tied STDOUT? Is that meant to be being defined explicitly somewhere initially? I grepped the code base for other ties to STDOUT, and I can't see any outside of this module.

I tried just dropping in use Apache2::compat into startup.pl, but that doesn't appear to have any affect on this.

I also notice in 15.4 of the ModPerl Cookbook a section on Filtered content where PerlSetVar Filter On is added to the config. Now I'm wondering why this code doesn't use that and whether I should be migrating the code to use it? Hmmm.

The mod_perl migration guide doesn't have any info on this. I'm assuming I should be reading up on details of stacked handlers or something similar. What should I be reading to get up to speed on how this worked under mod_perl 1, and how to get it working under mod_perl 2? (and any other insights welcomed).

Update: Found this presentation, which pretty much covers what I need to know. Long story short I need to look at Apache2::Filter


In reply to [RESOLVED] Migrating mod_perl app to mod_perl 2 by cLive ;-)

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.