Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何显示HTML表单中的多个条目?_Html_Perl_Functional Programming_Cgi - Fatal编程技术网

如何显示HTML表单中的多个条目?

如何显示HTML表单中的多个条目?,html,perl,functional-programming,cgi,Html,Perl,Functional Programming,Cgi,我有一个Perl CGI脚本。我试图在每一行显示用户条目,但它不起作用。以下是我目前掌握的情况: #!/usr/bin/perl use strict; use warnings; use CGI qw( :standard); print header; my %hash = ( 'Tyrone' => 1, 'Sue' => 1, 'Marshall' => 1,

我有一个Perl CGI脚本。我试图在每一行显示用户条目,但它不起作用。以下是我目前掌握的情况:

#!/usr/bin/perl
use strict; use warnings;
use CGI qw( :standard);

print header;
my %hash = (
             'Tyrone'   => 1,
             'Sue'      => 1,
             'Marshall' => 1,
             'Hiroshi'  => 1,
             'Jose'     => 1,
          )


print start_html(
    -title => 'Students in Class'
);

# Process an HTTP request
my $rollcall = param("names");
my @students_in_class = split(/;/, $rollcall);

foreach my $student (@students_in_class){
   if (exists $hash{$student}) {
       print h1('One student is '. $student . '<br>');
   } else {
       print h1('That student was sick today'. '<br>');
     }
}
#/usr/bin/perl
严格使用;使用警告;
使用CGI qw(:标准);
打印头;
我的%hash=(
“泰龙”=>1,
“Sue”=>1,
“马歇尔”=>1,
“Hiroshi”=>1,
“何塞”=>1,
)
打印开始html(
-title=>“课堂上的学生”
);
#处理HTTP请求
my$rollcall=param(“名称”);
my@students\u in_class=拆分(/;/,$rollcall);
foreach my$student(@students\u在班上){
if(存在$hash{$student}){
打印h1(“一个学生是“$student”。
”); }否则{ 打印h1(“那个学生今天生病了”。
); } }
如果用户在搜索栏中输入以下内容:
Tyrone;汤米;Marhshall

CGI应该产生以下输出

期望输出 一个学生是泰龙

那个学生今天生病了

一个学生是马歇尔



由于某些原因,它不起作用。

哈希定义后缺少分号

my %hash = (
         'Tyrone'   => 1,
         'Sue'      => 1,
         'Marshall' => 1,
         'Hiroshi'  => 1,
         'Jose'     => 1,
      );

根本不起作用?请尝试
perl-c yourperl.cgi
studentsInclass.cgi第15行附近的语法错误“)print”studentsInclass.cgi有编译错误。谢谢。有点高级的问题,但我犯了一个nooby语法错误。