[cgiapp] can AUTOLOAD sub be named AUTOLOAD?

rjmorris12 at gmail.com rjmorris12 at gmail.com
Wed Apr 16 11:30:47 EDT 2008


Perrin Harkins <perrin at elem.com> wrote on Wed, Apr 16, 2008 at 09:30:48AM -0400:
> On Tue, Apr 15, 2008 at 11:09 PM,  <rjmorris12 at gmail.com> wrote:
> >  Am I forced to name the AUTOLOAD
> >  method something other than AUTOLOAD?
> 
> Doctor, it hurts when I do this...

:)  Yes, I realize it seems somewhat trivial, but here's my rationale: If I
must name the AUTOLOAD method something other than AUTOLOAD, then I am
forced to use the hash version of run_modes() in setup(). Since all my
run mode methods have the same name as the run modes themselves, I must
enter each run mode's name twice:

  $self->run_modes(
    "mode1" => "mode1",
    "mode2" => "mode2",
    "AUTOLOAD" => "catchall"
  );
      
instead of:
      
  $self->run_modes([qw/
    mode1
    mode2
    AUTOLOAD
  /]);

I'd prefer to do without the redundancy. I can of course live with it or
come up with workarounds, but I wanted to check whether this might be a bug
before going one of those routes.

*Really* what I want to do (and now the truth comes out) is use
CAP::AutoRunmode like this:

  # no need for run_modes() in setup()
  
  sub mode1 : Runmode {}
  sub mode2 : Runmode {}
  sub AUTOLOAD : Runmode {}

but that suffers the same problem. I can come up with a workaround:

  $self->run_modes("AUTOLOAD" => "catchall");

  sub mode1 : Runmode {}
  sub mode2 : Runmode {}
  sub catchall {}

which isn't too bad. But if the AUTOLOAD problem is a bug that can be fixed
easily, then I'd rather do that than use this workaround. Another possible
solution would be to add an AutoloadRunmode attribute to CAP::AutoRunmode:

  # no need for run_modes() in setup()
  
  sub mode1 : Runmode {}
  sub mode2 : Runmode {}
  sub catchall : AutoloadRunmode {}


More information about the cgiapp mailing list