[cgiapp] CGI::App - creating your own overloaded functions

Rhesa Rozendaal perl at rhesa.com
Tue Aug 25 13:31:57 EDT 2009


Brad Van Sickle wrote:
> I find myself duplicating a lot of postrun code, so I'd like to move 
> that entire function up to a superclass file to centralize it.
> My problem with doing that is that at I still have some logical 
> constructs that I need to set somewhere in each modules that are 
> module/runmode dependent.

[snip]

> So what I've done is created a module in my superclass:*
> *sub app_module_define_JS*
> *    {*
> *    my $self = shift;*
> *    return;*
>    }*
> I then call that module at the start of post run*
> my $JSIncludes=&app_module_define_JS;*

That should be:

   my $js = $self->app_module_define_JS;

otherwise it isn't OO. &foo is the sub defined in the current package, so 
you're disabling method dispatch.

HTH,
rhesa


More information about the cgiapp mailing list