Query a Perl CGI : Socket « Network « Perl






Query a Perl CGI

    


use LWP::Simple;
use URI::URL;

$url = url('http://www.yourserver.com/cgireader.cgi');

$url->query_form(text1 => 'Hello', text2 => 'there');

$html = get($url);

print $html;


#File: cgireader.cgi

#!/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; 

   
    
    
    
  








Related examples in the same category

1.Time Server with Socket
2.Using Socket to call a Perl CGI
3.Socket server
4.Perl Modules for Networking with Sockets
5.Open a socket
6.Post query to a CGI
7.Listen to a port
8.Using regular expresion to validate an IP address
9.Child handle and parent handle
10.Daytime client, using symbolic host and service names
11.Add a host, delete a host, add a user, delete a user, ping a host, list processes, list filesystems, lists hosts, and kill a process.
12.A Perl TCP server without the Socket module.
13.A Simple script to update your host/ip with dyndns.org service.