I have a Perl CGI script. I would like to make a dynamic, appropriately-sized table based on query information from a simple HTML form: http://jsfiddle.net/wBgBZ/4/. I wanted to use HTML::Table but the server doesn't have the module installed. The administrator won't install it either. Therefore, I have to do it the old fashion way.
Here's what I have so far.
#!/usr/bin/perl
use strict; use warnings;
use CGI qw( :standard);
print header;
print start_html(
-title => 'Creating Tables'
);
# Process an HTTP request
my $query = param("names");
my @students_in_class = split(/;/, $query);
my %attributes = (
'Tommy' => 'A star baseball player who has lots of potential to play in the Major League of Baseball. ',
'Tyrone' => 'An honor roll athlete. His father is really proud of him. When he graduates, he wents to work at the National Institute for Public Health. His father wants him to become a doctor but he wants to pursue Physics.',
'Marshall' => 'A professional WWE wrestler.',
);
print table({-border=> undef},
caption('Students in the class'),
Tr({-align=>'CENTER',-valign=>'TOP'},
[
th(['Student', 'List of Attributes']),
foreach (@students_in_class){ # !!!!! problem line !!!!!!
td(['$_' , '$attributes{$}']),
}
]
)
);
Such that if the user enters the following into the search bar: Tyrone;Tommy;Marshall
the CGI should produces something similar to the following
Desired Output
If the user enters just Marshall;Tommy, the table should be 3x2.
It doesn't work. I need a way to dynamically add rows to the table.
Student | List of Attributesis considered a row.