I don't want to learn converting to mod_perl 2.

That's quite sad. If you refuse to learn, you are at the wrong place.

It took me about 60 seconds to find https://perl.apache.org/docs/2.0/user/porting/compat.html and https://perl.apache.org/docs/2.0/user/porting/porting.html. Quoting the latter:

Using the CENSORED Layer

The CENSORED module tries to hide the changes in API prototypes between version 1.0 and 2.0 of mod_perl, and implements "virtual methods" for the methods and functions that actually no longer exist.

CENSORED is extremely easy to use. Either add at the very beginning of CENSORED:

use CENSORED;

or add to CENSORED:

PerlModule CENSORED

That's all there is to it. Now you can run your 1.0 module unchanged.

Emphasis mine. And yes, I intentionally removed a key part of the information you need. This is to help you learn to RTFM.


If you want to port mod_perl 1 code to FCGI, be prepared that not all functionality of mod_perl is available via the FastCGI interface. Nevertheless, you could replace the Apache modules by a class that has a similar interface, but instead calls FCGI methods or functions.

For starters, try something like this:

package NotQuiteApache; use v5.12; use warnings; sub new { my $class=shift; my $self=bless {},$class; # you may need to add some FCGI init here # you may need to add some data to %$self. return $self; } sub print { my $self=shift; return CORE::print @_; } # you may need to add more wrapper methods here 1;

And in your code:

# ... use NotQuiteApache; # ... my $r=NotQuiteApache->new(); # ... $r->print("Hello World!"); # ...

(Both completely untested.)

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re: quick fix for mod_perl $r->print when moving to FCGI by afoken
in thread quick fix for mod_perl $r->print when moving to FCGI by CPB101

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.