Re: [QUESTION] Overloading/overriding print() when subclassing Apache
[prev]
[thread]
[next]
[Date index for 2005/05/16]
Arne Skjaerholt wrote:
> Hello all,
> I'm currently working on a project where I've decided to subclass
> Apache, and one of the methods I've decided to overload is the print
> method (so that my main module decides when data actually gets printed,
> not user modules). Now, I'd like to also override the built-in perl
> print (like Apache has done) so that module authors can say print
> ( @my_data ) instead of MyModule::Request->print ( @my_data ).
> Currently I've tried the following:
> sub PRINT
> {
> MyModule::Request->print ( @_ );
> }
> *print = \&PRINT;
>
> and:
>
> # Same PRINT() as above.
> *CORE::GLOBAL::print = \&PRINT;
>
> and:
>
> *CORE::print = \&PRINT;
> None of them have garnered any success worth mentioning. Explicitly
> saying MyModule::Request->print ( @my_data ); works as I intended. Does
> anyone have any ideas as to what I'm doing wrong here?
You don't say which mod_perl version you are using, Arne.
mp1 uses a tied STDOUT handle, so the correct way to do that is to
subclass the Apache package with overriden PRINT method.
mp2 uses PerlIO or the tie interfaces depending on the used perl.
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@xxxxxx.xxx http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
 |
 |
Re: [QUESTION] Overloading/overriding print() when subclassing Apache
Stas Bekman 15:34 on 16 May 2005
|