This is an HTML output problem. The key is in those uses you make of CGI.pm's HTML generation methods. What you want presumably (I'm assuming you have one row of data in your example), is a table with each column's label on the top (in the first row of that column) and each subsequent row containing the value for that entry. Here's how the HTML should look:

<tr> <td>Game Name</td> <td>Online Players</td> <td>Avg. Time</td> </tr> <tr> <td>Star Wars</td> <td>blah</td> <td>blah</td> </tr>

Without knowing what %dvalue holds, I'd guess that the 'offending' lines are

print $query->Tr($query->td([$var])); print $query->Tr($query->td(["$dvalue{$var} $dname{$var}"]));

In both cases, you're passing td an anonymous array holding a single value ($var in the first, a concatenation of two hash values in the second). That will print out a single td tag in both cases; and since you've got those wrapped in Tr calls, those end up on two different rows.

What you're getting, in other words is

<tr> <td> ( value of $var )</td> </tr> <tr> <td>(values of the two hash entries )</td> </tr>

You need to work to understand how these functions work, how that code translates to HTML ( or maybe you need to understand more HTML ).

Finally, just because CGI.pm *can* generate HTML doesn't mean you *need* to use it to =) Look into doing things by hand a bit, it may help out here.

perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'

In reply to Re: print output by arturo
in thread Help with CGI.pm's Table commands by swarddb

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.