CGI question

Ed Eddington ed at pcr7.pcr.com
Mon Aug 30 15:46:50 CDT 1999


You could use the LWP module to make the HTTP request to the second CGI 
program. The results of the request (whatever it be, HTML or text) is 
returned in a scalar. Look at LWP::Simple or LWP::UserAgent

Here's a tiny program that illustrates LWP::Simple  (Useragent isn't much 
harder to use). Just supplement the URL for the CGI plus paramters in a 
URL-encoded string 
(http://somewhere.com/program.cgi?field1=value1&field2=value2).

Ed


#!/usr/local/bin/perl

# Testing LWP:Simple - a simplified view of the lib-www interface
# See usage by: perldoc LWP::Simple
#           or: perldoc LWP

use LWP::Simple;

#get and print a web page to stdout
getprint "http://www.pm.org";


# OR pull response into a scalar
$url  = 'http://www.pm.org';
$response = get($url);
print $response;

# Save a page to disk by
getstore ($url, $file);    #store page
mirror   ($url, $file);    #store "IFMODIFIEDSINCE" or content length 
different




----------
From: 	Brandon Gohsman[SMTP:brandon at squareonedesign.com]
Sent: 	Monday, August 30, 1999 4:25 PM
To: 	GR Perl Mongers Mailing List
Subject: 	CGI question

Greetings,

I have a client who pays a monthly fee for delayed stock data from a data
service. To get the data, you call a CGI script from your web page with a
few arguments. A text-only file is returned with the data for their stock
symbol. This all works fine and dandy.

My problem is that the unformatted text looks ugly when poured into their
well designed web site layout. And, since there are no HTML tags, I can't
even use JavaScript to make dynamic changes. So what I want to do is 
capture
this returned text in an array or a series of scalars using Perl. Once I 
get
that to work, I can perform various sub-string functions to tear the text
apart, build a web page and return it.

Right now, I am at a loss on how to call one CGI script with another and
capture the returned text. The rest of it seems fairly straight forward if 
I
can just get that far.

If anyone knows how to do this or can point me in a direction that I 
haven't
gone, that would be great. Until then, I'll continue to scour my reference
books.

Thanks,

Brandon Gohsman
Square One Design
560 5th Street NW, Suite 301
Grand Rapids, MI 49504

T 616.774.9048
F 616.774.8003
E brandon at squareonedesign.com






More information about the grand-rapids-pm-list mailing list