When I need a switch I normally do something like this:
my %switch = ( default => \&list_ads, submit_payment => \&save_payment, set_duration => \&set_duration, go_here => sub {print 'hi'}, ); my $value = "go_here"; if (defined($value) && exists($switch{$value})) { $switch{$value}->(); } else { $pages{'default'}->(); }
In reply to Re: Simple Switch statement
by tantarbobus
in thread Simple Switch statement
by knexus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |