"Michael Graham" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > > How do I determine if the cgi_prerun has already been set? If it is set > > how would I add my own "prerun" code to it? > > If you're only interested in running your code without trampling on an > existing cgiapp_prerun, you have a couple of options. > > The first option is to call your superclass's cgiapp_prerun from within > your own: > > package MyApp; > use base 'MyProject'; > > sub cgiapp_prerun { > my $self = shift; > > # ...do my own prerun stuff > > # call existing cgiapp_prerun first > $self->SUPER::cgiapp_prerun(@_); > > # ...do some more of my own prerun stuff > > } > > And the second option (if you're using CGI::Application version 4.x) is > to install a prerun callback: > > package MyApp; > use base 'MyProject'; > > sub cgiapp_init { > my $self = shift; > > $self->add_callback('prerun', \&my_prerun); > } > > sub my_prerun { > my $self = shift; > > # ...do my own prerun stuff > > } > > Since you're not overwriting the existing cgiapp_prerun method, this > second strategy also allows you to tell whether or not there is a > cgiapp_prerun installed using 'can': > > if ($self->can('cgiapp_prerun')) { > # yup, there's a cgiapp_prerun there! > } > > > Michael >
Thanks Michael! Robert --------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/cgiapp@lists.erlbaum.net/ http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]