in reply to CGI::Application and inheritance

The way I usually do this sort of thing is place the following in the base class:

package BaseClass; use base 'CGI::Application'; sub cgiapp_init { my $self = shift; $self->run_modes('mode1_common' => \&mode1_common, 'mode2_common' => \&mode2_common); }

Then in the derived class I have the standard:

package DerivedClass; use base 'BaseClass'; sub setup { my $self = shift; $self->start_mode('start'); $self->run_modes([qw(derived_mode1 derived_mode2)]); }

As the CGI::Application documentation for cgiapp_init states:

If implemented, this method is called automatically right before the setup() method is called. This method provides an optional initialization hook, which improves the object-oriented character- istics of CGI::Application. The cgiapp_init() method receives, as its parameters, all the arguments which were sent to the new() method.

Replies are listed 'Best First'.
Re: Re: CGI::Application and inheritance
by geektron (Curate) on May 19, 2004 at 20:28 UTC
    that's the key. i missed that in the docs.

    i've been using cgiapp_prerun .. but not cgiapp_init