Even after I adding those tags, I couldnt get output in a table format
Modified Code
#!/usr/local/bin/perl -w
use strict;
use CGI;
my %host=( 'camel', 'flea', 'frog', 'green');
cgiout();
sub cgiout {
my $q= new CGI;
print $q->header;
print $q->start_html;
my $tablecontent=[$q->th(['key', 'value'])];
for (sort keys %host) {
push @$tablecontent, $q->td([ $_, $host{$_} ]) ;
}
print $q->table( { border => 1, -width => '100%'},
$q->Tr( $tablecontent),
);
print $q->end_html;
}
Output
Content-Type: text/html; charset=ISO-8859-1
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U
+S">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1
+" />
</head>
<body>
<table width="100%" border="1"><tr><th>key</th> <th>value</th></tr> <t
+r><td>camel</td> <td>flea</td></tr> <tr><td>frog</td> <td>green</td><
+/tr></table>
</body>
</html>
|