cLive ;-) has asked for the wisdom of the Perl Monks concerning the following question:

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, 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