perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jesse Erlbaum" <je...@erlbaum.net>
Subject RE: Speed of "if,elsif" versus $hash ...
Date Thu, 08 May 2003 10:56:29 GMT
Hi Jim --

> I just had a thought.. Maybe it's not a great one, but I'd appreciate
> some guidance..
> 
> I tend to start my scripts with a big if like :
> 
> 	if 	( $method eq 'foo' ){ do_something(); }
> 	elsif ( $method eq 'bar' ){ do_somethingelse();}
> 	etc..


If you're thinking about switching from an if-elsif-else structure to a
hash table for your web apps, you might want to take a look at
CGI::Application -- 

  http://search.cpan.org/search?dist=CGI-Application

This module is the natural result of exactly that line of thinking.  In
it you may specify a table of web application methods, which are
referred to as "run modes":

  $self->run_modes(
      foo => "do_something",
      bar => "do_somethingelse"
  );

You just write the functions and CGI-App handles everything else.  Check
out this article if you want a quick primer:

  http://www.perl.com/pub/a/2001/06/05/cgi.html


Warmest regards,

-Jesse-


--

  Jesse Erlbaum
  The Erlbaum Group
  jesse@erlbaum.net
  Phone: 212-684-6161
  Fax: 212-684-6226




Mime
View raw message