perl--CGI编程之测试环境

来源:互联网 时间:1970-01-01

可以用cgi对环境进行读取,直接用pint语句打印出来

#!d:/perl/bin/perl
use warnings;
use strict;

print "Content-type:text/html/n/n";
print "<HTML><HEAD><TITLE>Request Info</TITLE><HEAD> /n";

print "<BODY><BLOCKQUOTE><TABLE BORDER =1>/n";
foreach ('REQUEST_URI','REQUEST_METHOD','QUERY_STRING','PATH_INFO') {
 print "/t<TR><TD> $_ </TD><TD>'";
 print + (exists($ENV{$_}) and $ENV{$_})?$ENV{$_}:'Not provided';
 print "</TD></TR> /n";
}
print "</TABLE> /n";
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
 print "<BR><HR><BR> Request body:  /n";
 while (<>) {
  print "$.: $_ /n";
 }
}
print "</BLOCKQUOTE></BODY></HTML> /n";

用cgi编写表格

#!d:/perl/bin/perl
use warnings;
use strict;

use CGI::Pretty qw(:standard);

print header,start_html("Table Demo");

print table(Tr({-align=>'center',-valign=>'middle'},[
 td(['Tic','Tac','Toe','Tie']),
 td(['Red','Blue','Green','Yellow']),
 td({-colspan=>2},['Left','Right']),
 ]));
 
print end_html;


相关阅读:
Top