in reply to Regarding the conditional part of eslif (or if) statement
Thanks Again Monks.
I see as usual there is more than one way to tackle any problem including being a bad coder LOLS. I did go for the extra elsif statements in the end as shown in the code below as there was only 4 elements in the array.
my $y =1; foreach my $key1 (sort keys %outdate) { if ($outdate{$key1} eq $tacho) { $worksheet1->write_blank($r, $y, $tachosquare); } if ($outdate{$key1} eq $mot) { $worksheet1->write_blank($r, $y, $motsquare); } if ($outdate{$key1} eq $motlec) { $worksheet1->write_blank($r, $y, $motlecsquare); } foreach (@pmis) { if($outdate{$key1} eq $_){ $worksheet1->write_blank($r, $y, $pmisquare); } } if ($lec) { if ($lec eq $outdate{$key1} && $tacho eq $outdate{$key1} ) { $worksheet1->write($r, $y, "L", $tacholecsquare); } elsif ($pmis[0] eq $outdate{$key1} && $lec eq $outdate{$key1} ){ $worksheet1->write($r, $y, "L", $pmilecsquare); } elsif ($pmis[1] eq $outdate{$key1} && $lec eq $outdate{$key1} ){ $worksheet1->write($r, $y, "L", $pmilecsquare); } elsif ($pmis[2] eq $outdate{$key1} && $lec eq $outdate{$key1} ){ $worksheet1->write($r, $y, "L", $pmilecsquare); } elsif ($pmis[3] eq $outdate{$key1} && $lec eq $outdate{$key1} ){ $worksheet1->write($r, $y, "L", $pmilecsquare); } else { if ($outdate{$key1} eq $lec) { $worksheet1->write($r, $y, "L", $lecsquare); } } } $y++; }
I could not at the time get my head around a more logical way of writing it
note this code is inside a bigger while loop
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regarding the conditional part of eslif (or if) statement
by wfsp (Abbot) on Sep 19, 2010 at 09:10 UTC | |
by ramjamman (Sexton) on Sep 25, 2010 at 23:53 UTC | |
by ikegami (Patriarch) on Sep 26, 2010 at 00:38 UTC |