friedo has asked for the wisdom of the Perl Monks concerning the following question:
I've recently been playing around with CGI::Application which I like a lot.
Every time I add a new runmode method, though, I forget to add it to the list that must be supplied to the run_modes method in the setup phase. Consequently, every time I try to run my app with a new mode, I get an error. "This is far too much work," I hollered, and changed my run_modes invocation to this:
package MyApp; use strict; use warnings; use base 'CGI::Application'; sub setup { my $self = shift; # ... other stuff my @modes = grep /^rm_/, keys %MyApp::; $self->run_modes( map { /rm_(.*)/ => $_ } @modes ); }
Sure enough, that nicely maps ?rm=foo to the method rm_foo and I can now add modes to my heart's content.
But it does kinda give me the heebie-jeebies. Anyway,
Much obliged, friedo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI::Application - A little too lazy?
by astroboy (Chaplain) on Aug 07, 2005 at 11:39 UTC | |
|
Re: CGI::Application - A little too lazy?
by leriksen (Curate) on Aug 07, 2005 at 10:45 UTC | |
|
Re: CGI::Application - A little too lazy?
by samtregar (Abbot) on Aug 07, 2005 at 15:43 UTC | |
by Tanktalus (Canon) on Aug 07, 2005 at 15:55 UTC | |
by friedo (Prior) on Aug 07, 2005 at 16:13 UTC | |
|
Re: CGI::Application - A little too lazy?
by Anonymous Monk on Aug 07, 2005 at 10:13 UTC |