On Jul 3, John Edwards said:
>It's messy and relies on you naming you subroutines to match the static data
>stored in %funcs. It will introduce more possible points of failure in the
>code, make it harder to debug and maintain. Unless you've got a really good
>reason why you need to do this, I'd suggest you don't.
I *strongly* disagree. If you've never used a dispatch table, you're not
aware of the power and simplicity they bring.
%actions = (
login => \&welcome,
authent => \&checkpass,
logout => \&cleanup,
request => \&servepage,
);
if (my $function = $actions{$state}) { $function->(@_) }
else { die "unknown state '$state'" }
Dispatch tables (hashes of function references) are a Larry-send. ;)
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** Manning Publications, Co, is publishing my Perl Regex book **