Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Tables and CGI.pm

by Baz (Friar)
on Mar 24, 2004 at 13:35 UTC ( [id://339388]=perlquestion: print w/replies, xml ) Need Help??

Baz has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm attempting to plot a table with the following code -
my %verb = ( 'Bog' => 'Move', 'Bris' => 'Break', 'Buail' => 'Strike', ); print $h->center ( $h->table ( $h->Tr ( $h->td ( "Top" ) ), map { $h->Tr ( $h->td ( $verb{$_} ) ) }keys %verb, $h->Tr ( $h->td ( 'Bottom' ) ) ) );
But this is giving me -
<center> <table> <tr><td>Top</td></tr> <tr><td>Strike</td></tr> <tr><td>Break</td></tr> <tr><td>Move</td></tr> <tr><td></tr> </table> </center>
any ideas why? And is there a better way of doing this because it gets messy when I begin to format the table and add more columns etc. Cheers. Barry.

Replies are listed 'Best First'.
Re: Tables and CGI.pm
by dragonchild (Archbishop) on Mar 24, 2004 at 13:39 UTC
    You asked for the keys, which are 'Bog', 'Bris', and 'Buail'. You then asked for the value corresponding to each key, which is what you put in your table. Sounds like it's doing what it should!

    As a sidenote - is there a specific reason you aren't using something like HTML::Template or Template Toolkit? Or, heck, even HTML::Table??

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

      Where is "bottom"?
      and why am i getting  <tr><td></tr>with no </td>
      >>As a sidenote - is there a specific reason you aren't using something like HTML::Template or Template Toolkit? Or, heck, even HTML::Table??

      I'll check them out. Thanks.
        Oh. Put parentheses around your map and that will fix it. map is mapping the rest of your line, too.

        ------
        We are the carpenters and bricklayers of the Information Age.

        Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://339388]
Approved by Limbic~Region
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2024-04-18 22:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found