zoukankan      html  css  js  c++  java
  • CGI的函数

    CGI 不是语言而是common language gateway, 是借助STDIN, STDOUT来操作,简单的例子,

    #!/usr/bin/perl -wT
    print "Content-type: text/html\n\n";
    print <<EndOfHTML;
    <html><head><title>Test Page</title></head>
    <body>
    <h2>Hello, world!</h2>
    </body></html>
    EndOfHTML
    

    把以上cgi,放在www docuements的目录里,

    访问 http://www.cgi101.com/book/ch1/third.cgi

    CGI.pm Module

    The CGI.pm 模块式 Perl  5.004里面的标准库。

    use CGI qw(:standard);
    
    The qw(:standard) 表示我们从CGI.pm.调用"standard" 函数。
    
    调用函数,如果不传参数,可以不要括号,如下,
    functionname(arguments)
    
    CGI.pm有很多函数,我们可以用的如以下几个,
    
    header;
    start_html;
    end_html;
    
    例如,print start_html("Hello World");会打印出,
    <html>
    <head>
    <title>Hello World</title>
    <head>
    <body>
    
    例如,print start_html(-title=>"Hello World",
    	-bgcolor=>"#cccccc", -text=>"#999999",
     -background=>"bgimage.jpg");
    会打印出如下,
    <body bgcolor="#cccccc" text="#999999"  background="bgimg.jpg">
    
    end_html 会打印如下的标签
    
    </body>
    
    </html>
    
    因为perl是OO的,你可以完全读懂以下两段程序是一个意思,
    
    use CGI qw(:standard);
    
    print header;
    
    print start_html("Hello World");
    
    以下是OO的,
    
    use CGI;                    # don't need qw(:standard)
    $cgi = CGI->new;         # ($cgi is now the object)
    print $cgi->header;      # function call: $obj->function
    print $cgi->start_html("Hello World");
    
    再上一个完整的程序,
    
    #!/usr/bin/perl -wT
    use CGI qw(:standard);
    print header;
    print start_html("Hello World");
    print "<h2>Hello, world!</h2>\n";
    print end_html;
    
  • 相关阅读:
    docker-compose 命令不存在
    linux安装rabbitmq ssm集成rabbitmq
    tomcat参数错误 服务器400
    无限极分内 自联查询
    图片移入变大 点击图片切换 点击按钮显示图片
    js正则表达式基本书写
    随鼠标移动
    输入电话号码
    添加新句子
    窗口的弹出与关闭
  • 原文地址:https://www.cnblogs.com/cosiray/p/2409735.html
Copyright © 2011-2022 走看看