in reply to problem with a regex loop
Your code would call the two item() methods several times, it's wastefull both at run time and when you typed it.
SWITCH: for ($Request->item("View")->item()) { if ($_ eq 'HowTo') { $str .= mHowTo(); last SWITCH; if ($_ eq 'Tutorials') { $str .= mTutorials(); last SWITCH; ... }
It might be even better to use a hash like this:
my %actions = ( HowTo => \&mHowTo, Tutorials => \&mTutorials, ... ); ... sub tSupport { my $view = $Request->item("View")->item(); return exists($actions{$view}) ? $actions{$view}->() : mSearch(); }
|
|---|