• perlcgi基础


    代码: http://xxxxx/cgi/perl-cgi.cgi?name=itech&url=itech.cnblogs.com&p1=test1

    #!/usr/bin/perl -wT
    #should use strict and warnning

    use warnings;
    use strict;
    use CGI;
    #to debug error
    use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
    #or debug from command line by : perl -cwT yourcgi.cgi
    #or debug by : tail /var/log/apache/error_log
    #make sure yourcgi.cgi is world excutable or 755 permission
    #just include sub features of cgi, standard means, 'html2', 'html3', 'html4', 'form' and 'cgi'.
    #use CGI qw(:standard);

    #must define and initialize

    my $p1='';
    my $p2='';
    my $name='';
    my $url='';
    my $q = new CGI;
    $p1   = $q->param('p1') if $q->param('p1');
    $p2   = $q->param('p2'$q->param('p2') ;
    $name = $q->param('name'$q->param('name') ;
    $url  = $q->param('url'$q->param('url');

    print $q->header();
    print $q->start_html(-title=>"Hello World");

    print "p1:$p1<br>";
    print "p2:$p2<br>";
    if(!defined($p2)){print "p2 is not defined<br>";}
    if($p2 eq ""){print "p2 is empty<br>";}

    print <<EndHTML;
    <h2>Hello</h2>
    <p>
    My name is $name, and my web url is
    <a href="$url">$url</a>.
    </p>
    EndHTML

    $q->h3('welcome to here!<br>');
    print "$ENV{REMOTE_ADDR}<br>";
    print $q->end_html();  


    完! 

  • 相关阅读:
    SQL SELECT DISTINCT 语句
    SQL SELECT 语句
    SQL 语法
    Linux 命令大全
    MySQL 安装
    Nginx 安装配置
    linux yum 命令
    Linux 磁盘管理
    Linux 文件与目录管理
    Linux 用户和用户组管理
  • 原文地址:https://www.cnblogs.com/itech/p/2698553.html
Copyright © 2020-2023  润新知