D
danilche
Hiyall,
I need to write some custom handlers for Apache/mod_perl, and I would
like them to be subclassed. THis is really a Perl problem, not an
Apache or mod_perl problem. I am hoping someone here will be able to
enlighten me about a good way to do this.
The structure is like this:
package Parent;
sub custom_func {
....
}
sub handler {
custom_func;
...
}
package Child;
use base 'Parent';
sub custom_func {
}
1;
The problem is that mod_perl calls Parent::handler or Child::handler
function -- there is no object instantiation, no blessed references,
and no polymorphism. However, I need the Child class to inherit the
handler from parent (which it does), and then within the handler I need
it to call the correct custom_func definition. As it is, whenever
Child::handler is called, it is routed to Parent::handler, but then
Parent::handler always calls Parent's custom_func, not Child's
custom_func.
Basically, I am looking to get polymorphism to work on packages rather
than classes. Is there a reasonably easy way to do it?
I need to write some custom handlers for Apache/mod_perl, and I would
like them to be subclassed. THis is really a Perl problem, not an
Apache or mod_perl problem. I am hoping someone here will be able to
enlighten me about a good way to do this.
The structure is like this:
package Parent;
sub custom_func {
....
}
sub handler {
custom_func;
...
}
package Child;
use base 'Parent';
sub custom_func {
}
1;
The problem is that mod_perl calls Parent::handler or Child::handler
function -- there is no object instantiation, no blessed references,
and no polymorphism. However, I need the Child class to inherit the
handler from parent (which it does), and then within the handler I need
it to call the correct custom_func definition. As it is, whenever
Child::handler is called, it is routed to Parent::handler, but then
Parent::handler always calls Parent's custom_func, not Child's
custom_func.
Basically, I am looking to get polymorphism to work on packages rather
than classes. Is there a reasonably easy way to do it?