Update: ++TomDLux , beat me to the punch! Signing up for the monastery is a great idea.
HTML::Template will save your bacon. Specifically its looping feature. Design the layout of a table/cell for one switch status. Insert place holders into the relevant fields, and a template loop around the whole deal.

<html> <body> <table border=3> <TMPL_LOOP switches> <tr> <td> <TMPL_VAR hostname> </td> <td> <TMPL_VAR status> </td> </tr> </TMPL_LOOP> </table> </body> </html>

Then you can feed your data into that with HTML::Template

#!/usr/bin/perl -w use strict; use Data::Dumper; use HTML::Template; my $template = HTML::Template->new( filename=>'./switch-status.tmpl' ) +; my @hosts = ( qw/ switch cisco1 cisco2 ninety nine cisco5 / ); my $info = []; foreach my $host ( @hosts ) { my $data = { hostname=> $host, status => Host2Status($host) , }; push @$info , $data; } $template->param(switches=>$info); print $template->output; sub Host2Status { my $host = shift; my $rand_status = int (rand 2)-1; my $status = ($rand_status) ? "Cool" : "Froody"; return $status; }

This code works for me , no guarantees though. The cpan documentation for HTML::Template is good. If you are familiar with creating semi-complex datastructures in perl like an array of hashes, you will have this done in _NO_ time.


I can't believe it's not psellchecked

In reply to Re: Generating HTML from SNMP data by submersible_toaster
in thread Generating HTML from SNMP data by Anonymous Monk

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.