Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: CHECKING IF HEADER DEFINED

by DrHyde (Prior)
on Aug 04, 2010 at 16:18 UTC ( #852907=note: print w/replies, xml ) Need Help??


in reply to Re^3: CHECKING IF HEADER DEFINED
in thread CHECKING IF HEADER DEFINED

Working on the assumption that you would already have one sub per action (which probably calls several other subs in turn) and merely use the id/elsif/sleif/else to decide which to dispatch to, then I still fail to see what benefits CGI::Application gives you.

From the documentation, you are expected to do this:

sub setup { my $self = shift; $self->start_mode('mode1'); $self->mode_param('rm'); $self->run_modes( 'mode1' => 'do_stuff', 'mode2' => 'do_more_stuff', 'mode3' => 'do_something_else' ); }
which really is just another way of writing this:
if ($cgi{rm} eq 'mode1') { do_stuff } elsif($cgi{rm} eq 'mode2') { do_more_stuff } ...
it's just different boilerplate.

Replies are listed 'Best First'.
Re^5: CHECKING IF HEADER DEFINED
by trwww (Priest) on Aug 06, 2010 at 07:26 UTC

    The $self->run_modes stuff takes care of the HTTP headers for you, which is the exact problem the OP has. So its much more useful than a large conditional where you claim it is identical.

    If you don't like configuring the runmodes in the setup method, you can just use CGI::Application::Plugin::AutoRunmode.

    Also, once you go with CGI::Application, you immediately have all of the plugins that others have shared on CPAN so you don't have to keep reinventing wheels that have already been done better by others.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://852907]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2019-04-18 16:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I am most likely to install a new module from CPAN if:
















    Results (103 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!