in reply to What is the most efficient perl switch/case statement?
Since most of my work is Web based, i care more about maintainability and readability than efficiency .. but i do care about efficiency when it really matters.use strict; use warnings; use Tie::Hash::Regex; tie my %hash, 'Tie::Hash::Regex'; %hash = ( 'foo.txt' => 1, 'bar.html' => 2, '..' => undef, '.' => undef, DEFAULT => undef, ); my $arg = shift || 'DEFAULT'; my $candidate = $hash{$arg}; die "invalid arg\n" unless $candidate; print "$candidate\n";
UPDATE:
I forgot to mention CGI::Application which uses
a dispatch table to control which runmode your CGI is in.
If you haven't seen it yet, you really should RTFM on
CGI::App ...
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: What is the most efficient perl switch/case statement?
by synistar (Pilgrim) on Nov 21, 2003 at 15:24 UTC |