Reputation:
I'm trying to display a table with some information and I have this code for that:
print $q->start_html(-title => "user summary");
print $q->table({-border=>1},
$q->tr($q->th(["Info","Value"])),#header
$q->tr($q->td(["Date",$date_var])),#first row
$q->tr($q->td(["Uptime",$uptime])),#second row
$q->tr($q->td(["1 min",$avg_one])),#third row
$q->tr($q->td(["5 min",$avg_two])),#fourth row
$q->tr($q->td(["15 min",$avg_two])),#fifth row
);
but when I run it I get:
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-US">
<head>
<title>user summary</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
Undefined subroutine CGI::tr
at ./index.cgi line 30
where ./index.cgi line 30
refer to this line print $q->table({-border=>1
and on the webpage I get 500 Internal Server Error
so any ideas?
Upvotes: 0
Views: 80
Reputation: 69314
You've got the right answer (twice) already, but I just wanted to point you at the "Non-Standard HTML Shortcuts" section of the CGI documentation, which says:
A few HTML tags don't follow the standard pattern for various reasons.
comment() generates an HTML comment (). Call it like
print comment('here is my comment');
Because of conflicts with built-in Perl functions, the following functions begin with initial caps:
- Select
- Tr
- Link
- Delete
- Accept
- Sub
In addition, start_html(), end_html(), start_form(), end_form(), start_multipart_form() and all the fill-out form tags are special. See their respective sections.
Upvotes: 0
Reputation: 241968
tr
is a synonym of y
, the translation operator. Use Tr
for CGI's table row.
Upvotes: 0