Perl-CGI Basics

Source: Internet
Author: User

Code: Http: /xxxxx/cgi/perl-cgi.cgi? Name = itech & url = itech.cnblogs.com & p1 = test1

# ! /Usr/bin/perl-WT
# Shoshould use strict and warnning
Use Warnings;
Use Strict;
Use CGI;
# To debug Error
Use CGI: carp QW (warningstobrow.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

Hello



my name is $ name , and my web URL is
" $ URL " $ URL .


endhtml

$ Q-> H3 ('Welcome to here! <Br>');
Print "$ ENV {remote_addr} <br>";
Print $ Q-> End_html ();

Complete!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.