Subject: best way to create a table in Perl
Posted By: crmpicco Post Date: 6/20/2006 6:39:03 AM

print "<table border=\"1\" bordercolor=\"#000000\">";
    print "<tr>";
        print "<td>";
            print $weePit;
        print "</td>";
    print "</tr>";
print "</table>";


Is this the best way to create a table in Perl?

(i am a MAJOR nooB!)



Picco

www.crmpicco.co.uk
www.ie7.com
Reply By: ciderpunx Reply Date: 6/22/2006 11:15:21 AM
crmpicco - there's more than one way to do it - just printing it may be ok, though you may want to use a heredoc thus:

print <<EOF
<table style="border:1px solid #000;">
  <tr>
    <td>$WeePit</td>
  </tr>
</table>

EOF

# more code


You could use the CGI.pm way:

use strict;
use CGI;
my $q = new CGI;
print $q->header( "text/html" ),
$q->start_html( -title => "Table Example" ),
    $q->h1( "Table Example" ),
    $q->p( "This is a table.” ),
    $q->table( {style => 'broder:1px solid #000;'},
        $q->Tr( {align => "center"},
            [ $q->th( [ 'Heading 1', 'Heading Two', 'Heading 3' ] ),
              $q->td( ['x','y',$WeePit] ) ] )
        )
    ),
$q->end_html;


You could use HTML::Template, and a template like this:


<html>
<head>
  <title>Table Example</table>
</head>
<body>
  <table style="border:1px solid #000;">
    <tr>
      <td><TMPL_VAR NAME='WeePit'></td>
    </tr>
  </table>
</body>
</html>


I'd probably stick with just using print for now, until you have a better handle on perl.

--
Don't Stand on your head - you'll get footprints in your hair
                                           http://charlieharvey.org.uk
                                              http://charlieharvey.com
Reply By: crmpicco Reply Date: 11/21/2006 7:45:28 AM
thanks cyberpunx, much appreciated

www.crmpicco.co.uk
www.ie7.com

Go to topic 52387

Return to index page 115
Return to index page 114
Return to index page 113
Return to index page 112
Return to index page 111
Return to index page 110
Return to index page 109
Return to index page 108
Return to index page 107
Return to index page 106