简体   繁体   中英

CGI table with perl

I am trying to build a login form with CGI , using perl .

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 ?

Thank you for your help.

Why can I use you some subroutines?

Because you are likely importing them using the following use statement:

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'.

But that does not include the table methods.

To get them too, you can modify your use statement to the following:

use CGI qw(:standard *table);

Why does removing CGI-> print start_table as a string?

Because you unwisely do not have use strict turned on.

If you had, you would've gotten the following error:

Bareword "start_table" not allowed while "strict subs"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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