In our company, we used this code (given at the end) for about 10 years, and it worked fine.
A few days ago we encountered some problems, and we had to transcode the complete package, we decided to replace this code with the Switch Damian module (to improve the readability of the code).
Everything works great for us.
I later found in Perlmonks that Damian put this module under
Damian modules that you should not use in production, since their purpose is to study and prototype future functions of the main language.
But it works great for us, because we do not encounter the limitations of this module (I think).
Now I ask you guys to take a look at both implementations (nested if else vs switch), and let me know if using Switch is good in the new version, or are we creating some future problems for you? Is the use of Switch in the code below accurate or are there hidden errors / issues?
I already read about the errors and reviews of this module on CPAN and Perlmonks, and I think our code is far from getting into these errors (I think so).
We are using Perl 5.8.5 .
PS: I know the alternatives to Switch, we have given/when in Perl 5.10, we can use the dispatch table and other solutions that are listed here , but right now we just want to compare the new implementation that uses Switch.
Using nested if else
if ($command =~ /^enter$/) { $self->show_main_frames(); } elsif ($command =~ /^XYZ_MENU/i) { $self->show_main_menu($manual, $dbot); } elsif ($command =~ /^DBOT/i) { $dbot->process(); }
Using switch
switch ($command) { case /^enter$/ { $self->show_main_frames() } case /^XYZ_MENU/i { $self->show_main_menu($manual, $dbot) } case /^DBOT/i { $dbot->process() } case /^XML_DBOT/i { $dbot->process() } case /^UGS/i { $ugsui->process() } case "kill" { my $login = $self->{COMMON_HASH}{login} || ""; my $su_login = $self->{CONF}->get("start", "SU_LOGIN"); if ($login eq $su_login) {