With the latest things I've been working on, I've been trying to get into the Perl (and CGI.pm) way of thinking. This is a problem that struck me today, I just wasn't sure what to do, but it may require changing my data structures. This comes from a script I decided to put together to keep a current status of all our web sites so that my department (1 programmer working in a graphics design studio) doesn't get ignored. The data comes in like this :

my %sites; open (INFILE, "<sites.txt"); #data from file looks like this: #sitename|siteaddress|status|comments while (<INFILE>) { my($name, @status) = split/|/; $sites{$name} = @status; } close (INFILE);

Now I want to take %sites and print it into table. My first thought was that I would iterate over %sites with foreach and print a <td> each time, but when I was reading the CGI.pm documention, table() was totally different than I thought. What I want to do is print a table that looks roughly like this:

Site Name | Site Address       | Status             | Comments
$site     | $sites{$site}->[0] | $sites{$site}->[1] | $sites{$site}->[2]

Is this possible? Or does %sites need to change to @sites or a hash reference?

__________________________________________________
%mexnix = (email = > "mexnix@hotmail.com", website => "http://mexnix.perlmonk.org");


In reply to table()'s with CGI.pm by mexnix

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.