Re: Processing a web page (or looping over a multi line string)



Jason wrote:
> The problem I'm trying to solve:
> There's a status web page that this program needs to check. Any line
> that matches:
> ^\s<td>some information</td>
> is one that I need to process. I just need the 'some information'
> part.
>
> I found LWP::Simple, and I'm getting the webpage with 'get $url'. The
> problem is I can't figure out how to loop over the lines of HTML to
> find what I want.
>
> I've tried:
>
> my $content = get $url;

$content is one big scalar. One single string. If you want to operate
on the "lines" contained in that string, you'll have to tell Perl what
a "line" is, first:

foreach my $line (split /\n/, $content) {
process_line($line);
}

Hope this helps,
Paul Lalli

.