The code below breaks up the @stat_array into fours and then
prints out fields into an HTML table with the OCOMsg2 cell in red –
again – just one cell of the emailed table.
The boss told me that he wants the WHOLE LINE with the OCOMsg2
in red – so the array below, all the elements
"ibfarm102 - localtick", 'New York", "hibmis100 - procHKHD2 - Hongkong", "OCOMsg2"
need to be red.
Is there a way to do this with out rewriting the whole block – I really like this block.
@stat_array = ("ibfarm102 - localtick", "Boston" , "hibmis100 - procHKHD2 - Hongkong", "PidMonRsp",
"eufarm102 - localtick", "London", "hibmis100 - procHKHD2 - Hongkong" , "PidMonReq" ,
"ibfarm102 - localtick", "New York" , "hibmis100 - procHKHD2 - Hongkong", "PidMonRsp",
"ibfarm102 - localtick", 'New York", "hibmis100 - procHKHD2 - Hongkong", "OCOMsg2");
my @stat_array_rows = @stat_array;
while (my @stat_array_rows = splice(@stat_array_rows, 0 , 4)) {
print MAIL "<tr>\n";while (my @stat_array_rows = splice(@stat_array_rows, 0 , 4)) {
print MAIL "<tr>\n";
for my $stat_row(@stat_array_rows) {
if ($stat_row =~ /OCCOMsg2/){
print MAIL "<td><font color=red>$stat_row[0]</font></td>\n";
}
else {
print for my $stat_row(@stat_array_rows) {
if ($stat_row =~/OCAlive2/){
print MAIL "<td><font color=red>$stat_row[0]</font></td>\n";
}
else {
print MAIL "<td>$stat_row</td>\n";
}
}
print MAIL "</tr>\n";
}
these are the results of the block:
<tr>
<td>ibfarm102 - localtick </td>
<td> Boston</td>
<td> hibmis100 - procHKHD2 - Hongkong </td>
<td>PidMonRsp</td>
</tr>
<tr>
<td>eufarm102 - localtick </td>
<td>London</td>
<td> hibmis100 - procHKHD2 - Hongkong </td>
<td>PidMonReq</td>
</tr>
<tr>
<td>ibfarm102 - localtick </td>
<td>New York</td>
<td> hibmis100 - procHKHD2 - Hongkong </td>
<td>PidMonRsp</td>
</tr>
<tr>
<td>ibfarm102 - localtick </td>
<td>New York</td>
<td> hibmis100 - procHKHD2 - Hongkong </td>
<td><font color=red> OCOMsg2</font></td>
</tr>
I somehow want Perl to print everything i the OCOMsg2 block red, not just that cell.
When you have the data in @stat_array_rows (a rather badly named variable in my opinion as it only contains a single row at a time) you just need to check if any of the elements contains ‘OCOMsg2’ and set a flag which you can use within the rest of the code.
Also. This is 2011. People don’t use the FONT tag any more. You should use CSS for this.