[英]CGI table with perl
I am trying to build a login form with CGI
, using perl
. 我正在尝试使用
perl
使用CGI
构建登录表单。
sub show_login_form{
return div ({-id =>'loginFormDiv'}),
start_form, "\n",
CGI->start_table, "\n",
CGI->end_table, "\n",
end_form, "\n",
div, "\n";
}
I was wondering why I don't need to add CGI->
before start_form
but if I don't include it before start_table
and end_table
, "start_table"
and "end_table"
are printed as strings
? 我想知道为什么我不需要在
start_form
之前添加CGI->
,但是如果我在start_table
和end_table
之前不包括它, start_table
"start_table"
和"end_table"
打印为strings
吗?
Thank you for your help. 谢谢您的帮助。
Because you are likely importing them using the following use statement: 因为您可能使用以下use语句导入它们:
use CGI qw(:standard);
As documented in CGI - Using the function oriented interface , this will import "standard" features, 'html2', 'html3', 'html4', 'ssl', 'form' and 'cgi'. 如CGI中所记录-使用面向功能的界面 ,这将导入“标准”功能,“ html2”,“ html3”,“ html4”,“ ssl”,“ form”和“ cgi”。
But that does not include the table methods. 但这不包括表方法。
To get them too, you can modify your use statement to the following: 要获得它们,您可以将use语句修改为以下内容:
use CGI qw(:standard *table);
Because you unwisely do not have use strict
turned on. 因为您不明智地没有
use strict
打开。
If you had, you would've gotten the following error: 如果有的话,将会出现以下错误:
Bareword "start_table" not allowed while "strict subs"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.