我正在尝试在 perl 中构建一个网页,我从一个文本字段中获取一个名称,然后将它与一个数组进行比较。如果找到匹配项,我需要显示一些存储在文本文件中的相应内容。这是我的代码,
#!G:\perl\bin\perl.exe -w
use CGI qw/:standard/;
my $cgi = CGI->new;
my $action = $cgi->param('action');
my @team = qw( red blue green yellow );
print
header,
start_html('welcome'),
h1('welcome'),
start_form,
"Please Enter your name",textfield('name'),p, //can someone tell me what is ,p, doing here?
submit,
end_form,
hr,"\n";
my $n = $cgi->param('name');
for (my $i=0; $ <= $#team; $i++) {
if ( $team[$i] eq $n ) {
print "Welcome, $n";
}else {
print "who are you ?";
}
}
print end_html;
我的问题是我在获得名称后无法进行比较,也无法在获得名称后打印任何内容。另外是否可以更改提交按钮内的文本?