简体   繁体   English

带有Perl的CGI表

[英]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_tableend_table之前不包括它, start_table "start_table""end_table"打印为strings吗?

Thank you for your help. 谢谢您的帮助。

Why can I use you some subroutines? 为什么我可以使用一些子例程?

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);

Why does removing CGI-> print start_table as a string? 为什么删除CGI-> print start_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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM