Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Filtering failing under Apache & mod_perl?

by clueless newbie (Chaplain)
on Jul 19, 2010 at 13:31 UTC ( #850248=perlquestion: print w/replies, xml ) Need Help??
clueless newbie has asked for the wisdom of the Perl Monks concerning the following question:


I have a module (let's just call it Snitch) whose task is to catch, store and report that which goes to STDERR - along with the context and the source. It does this via tie (and Tie::StdHandle). Using Filter::Simple (and a FILTER block) I have integrated a very rudimentary form of Smart::Comment into Snitch to convert the comments of the form "### ..." into their code equivalent - namely:

### assert: boolean expression unless (boolean expression) { die the boolean expression is false +with a dump of the elements in the expression } ### verify: boolean expression unless (boolean expression) { warn the boolean expression is false + with a dump of the elements in the expression } ### dump: list if (DEBUG) { warn with a dump of the elements in the list } ### evaluate: expression if (DEBUG) { warn value of expression = expression } ### "string" if (DEBUG) { warn "string" } ### <Perl code> <Perl code>

By pushing a reference to a sub onto @INC Snitch "auto wires" any modules that it finds in the specified "private library".

Under Window 2k/Perl 5.10 all this works perfectly well from either the command line or xampp. On my work *nix devbox, it all works from the command line (perl 5.8.6). Under (devbox) Apache & mod_perl, there are no problems with the STDERR handling portion (I get the STDERR output along with the message context and the source), but the conversion from comment to code never occurs (neither in the user nor the wireable modules). (I should note that (devbox, Apache & mod_perl) while a "use Smart::Comments" causes no error, it too fails to convert its smart comments to code.) I did confirm that the commandline version and the Apache & mod_perl version are using the same modules.

Where's the sin and how do I atone for it?

Replies are listed 'Best First'.
Re: Filtering failing under Apache & mod_perl?
by kennethk (Abbot) on Jul 19, 2010 at 14:07 UTC
    When I hear that a source filter works in normal Perl environments but then fails under Apache & mod_perl, my mind jumps to the following line from BEGIN, UNITCHECK, CHECK, INIT and END in perlmod:

    The CHECK and INIT code blocks will not be executed inside a string eval(), if that eval() happens after the end of the main compilation phase; that can be a problem in mod_perl and other persistent environments which use eval STRING to load code at runtime.

      No doubt that I am being extremely dense, but I haven't seen anything in Filter::Util, Filter::Simple or Smart::Comments that hint that filtering does NOT work under mod_perl. Evidence to the contrary (other than "Your code isn't working under mod_perl") would be appreciated. Suggestions on how to make it work would be appreciated even more.

Re: Filtering failing under Apache & mod_perl?
by Anonymous Monk on Jul 19, 2010 at 13:48 UTC
    Where's the sin and how do I atone for it?

    5.8.6 is too old? You're being too clever and you're hoping someone has done this before? You don't show minimal code/config so we may replicate the problem?


      It does run under 5.8.6 from the command line. I'll need to do some trimming before I post code (Snitch including the css and Javascript is about 800 lines.).
Re: Filtering failing under Apache & mod_perl?
by sierpinski (Chaplain) on Jul 19, 2010 at 13:55 UTC
    Where's the sin and how do I atone for it?

    A good place to start is to post some code, and verify that you have 'use warnings;' somewhere in your code. ;-)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://850248]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2017-11-21 09:21 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (297 votes). Check out past polls.