perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jesse Erlbaum" <>
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 --

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":

      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:

Warmest regards,



  Jesse Erlbaum
  The Erlbaum Group
  Phone: 212-684-6161
  Fax: 212-684-6226

View raw message