docock
09-28-2007, 05:15 PM
I'm using the code below to fetch the html code of a page and store it in an array, the code seems a little long though, and the code is written to disk :S
How to shorten the code and place the code in an array without writing to disk?
#!/usr/bin/perl
use CGI;
$q=new CGI;
print "Content-Type: text/html; charset=utf-8\n\n";
use LWP::Simple;
my $url = 'http://www.mysite.com/results?search_query=gees';
my $file = 'booktv.txt';
my $status = getstore($url, $file);
open(FILE, "booktv.txt") or die("Unable to open file");
# read file into an array
@data = <FILE>;
# close file
close(FILE);
All I want to do is read an html file from a certain website, retrieve a line where a certain word occures and place that line into a string.. so if someone can rewrite it...that would be wonderfull (i'm a little noobish at cgi)
How to shorten the code and place the code in an array without writing to disk?
#!/usr/bin/perl
use CGI;
$q=new CGI;
print "Content-Type: text/html; charset=utf-8\n\n";
use LWP::Simple;
my $url = 'http://www.mysite.com/results?search_query=gees';
my $file = 'booktv.txt';
my $status = getstore($url, $file);
open(FILE, "booktv.txt") or die("Unable to open file");
# read file into an array
@data = <FILE>;
# close file
close(FILE);
All I want to do is read an html file from a certain website, retrieve a line where a certain word occures and place that line into a string.. so if someone can rewrite it...that would be wonderfull (i'm a little noobish at cgi)