[sf-perl] Can't figure this one out

Steve Fink sphink at gmail.com
Wed Mar 5 17:33:47 PST 2008

>  > By the way
>  >
>  > if ($action =~ /start/i) {
>  >         &MainPage($q, \%p);
>  > } elsif ($action =~ /new|del|edt|save/i ) {
>  >
>  > {
>  >
>  > seems better to me
>  It's more compact, but I bet it runs slower.  This might even be a
>  case where performance matters (i.e. if the cgi script sees a lot of
>  traffic).

I'll take that bet. I bet the all-regex version is faster. Especially
on newer versions of Perl that have the trie optimization, but even
without that I'd guess that it's faster. If I weren't so damn lazy,
I'd write a benchmark to test it. But I can't be bothered, because
there's no way that the performance of that line of code is going to
be significant compared to the processing and page generation. (And if
this is a CGI and not mod_perl, the startup time is going to be orders
of magnitude more than all that anyway.)

More information about the SanFrancisco-pm mailing list