Just looking at your
if ($lec){ #... }
block. As has been suggested replacing all those near indentical elsif blocks with a loop would be better.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.