你的分享就是我们的动力 ---﹥

POST 参数到 Perl CGI

时间:2013-05-30 00:15来源:www.chengxuyuans.com 点击:

POST 参数到 Perl CGI

use HTTP::Request::Common; 
use LWP::UserAgent;
$user_agent = LWP::UserAgent->new;
$request = POST 'http://www.chengxuyuans.com/cgireader.cgi',
    [text1 => 'Hello', text2 => 'there'];
$response = $user_agent->request($request);
print $response->as_string;

Perl代码片段

#!/usr/local/bin/perl

use CGI;                             

$co = new CGI;                        
print $co->header,                    

$co->start_html(
    -title=>'CGI Example', 
    -author=>'yourName', 
    -BGCOLOR=>'white', 
    -LINK=>'red'
);

if ($co->param()) {
    print 
        "You entered this text: ", 
        $co->em($co->param('text1')), 
        " ",
        $co->em($co->param('text2')), 
        ".";
} else {
    print "Sorry, I did not see any text.";
}

print $co->end_html; 

转载注明地址:http://www.chengxuyuans.com/Perl/63116.html