Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You'd better off using a template. For this purpose, I would go with <a href="http://search.cpan.org/perldoc/HTML%3a%3aTemplate" rel="nofollow">HTML::Template</a>. Coupled with <a href="http://search.cpan.org/perldoc/List%3a%3aMoreUtils" rel="nofollow">List::MoreUtils::natatime</a>, you can solve the problem cleanly.</p> <pre><code>#!/usr/bin/env perl use warnings; use strict; use HTML::Template; use List::MoreUtils qw( natatime ); my $tmpl = HTML::Template-&gt;new( scalarref =&gt; \ do {local $/; &lt;DATA&gt;} ); my @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 @rows; my $it = natatime 4, @stat_array; while (my @cells = $it-&gt;()) { push @rows, { CELLS =&gt; [map +{CELL =&gt; $_}, @cells], HIGHLIGHT =&gt; $cells[-1] eq 'OCOMsg2' }; } $tmpl-&gt;param(ROWS =&gt; \@rows); print $tmpl-&gt;output; __DATA__ &lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;body&gt; &lt;table&gt; &lt;TMPL_LOOP ROWS&gt; &lt;TMPL_IF HIGHLIGHT&gt; &lt;tr style="color:red"&gt; &lt;TMPL_ELSE&gt; &lt;tr&gt; &lt;/TMPL_IF&gt; &lt;TMPL_LOOP CELLS&gt; &lt;td&gt;&lt;TMPL_VAR CELL&gt;&lt;/td&gt; &lt;/TMPL_LOOP&gt; &lt;/tr&gt; &lt;/TMPL_LOOP&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload