Perl CGI スクリプトがあります。単純な HTML フォームhttp://jsfiddle.net/wBgBZ/4/からのクエリ情報に基づいて、動的で適切なサイズのテーブルを作成したいと思います。HTML::Tableを使用したかったのですが、サーバーにモジュールがインストールされていません。管理者もインストールしません。したがって、私はそれを昔ながらの方法で行う必要があります。
これが私がこれまでに持っているものです。
#!/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{$}']),
}
]
)
);
ユーザーが検索バーに次のように入力すると、次のようになります。Tyrone;Tommy;Marshall
CGI は、次のようなものを生成する必要があります。
望ましい出力
ユーザーが だけを入力した場合Marshall;Tommy
、テーブルは 3x2 になります。
うまくいきません。テーブルに行を動的に追加する方法が必要です。