block. As has been suggested replacing all those near indentical elsif blocks with a loop would be better.if ($lec){ #... }
If you have a default, set it at the begining and avoid an else block.
For within a small scope it also worth using a temp var to hold the value of a var with a long name that will be used many times. This also uses a temp "holding" var ($cell) so that the write method only appears once.
This approach helps eliminate a lot of repitition which can be confusing and hard to maintain. And it cuts down typing. :-)
# give ourselves a short name # in a short scope my $o = $outdate{$key1}; if ($lec and $lec = $o) { # set the default my $cell = $lecsquare; if ($tacho eq $o) { $cell = $tacholecsquare; } else { for my $i (0..3){ $cell = $pmilecsquare if $pmis[$i] eq $o; } } $worksheet1->write($r, $y, "L", $cell); }
In reply to Re^2: Regarding the conditional part of eslif (or if) statement
by wfsp
in thread Regarding the conditional part of eslif (or if) statement
by ramjamman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |