Gossamer Forum
Home : General : Perl Programming :

LWP problem, please help

Quote Reply
LWP problem, please help
Here is the cgi script Im using

#!/usr/local/bin/perl
use LWP::Simple;
#retrieve the page which should be modified
my $page = get("http://www.url.com");
$page =~ s/\n//g;
#everything above this will be cut off
$page =~ s/^.*<\/head>//is;
#everything below this will be cut off
$page =~ s/<\/body>.*$//is;
print "Content-type: text/html\n\n";
#print result
print "$page";

It works ok, except I want to use any html command to start and end cutting. It only works if I place a command like <HTML> or <BODY> or <HEAD>. Those are the only ones I can get to work. A little help please?
Quote Reply
Re: LWP problem, please help In reply to
Try changing
Code:
$page =~ s/^.*<\/head>//is;
to
Code:
$page =~ s/^.*<HR>//is;

[This message has been edited by pugdog (edited July 16, 1999).]
Quote Reply
Re: LWP problem, please help In reply to
The reason is that it's pulling out the 'body' of the page by cutting off everything above the '<BODY>' and everything below the </BODY>

Actually, you should still have the <body> tag in your file if I'm reading the code correctly.

What do you mean you want it to cut at any tag?

That sounds like you are trying to really parse the file, and there are parsing utilities out there.

Scott
Quote Reply
Re: LWP problem, please help In reply to
What I mean is that an I start a cut at the command <HR> and end at </BODY>?

Do you know of any good parsing utilities?