in reply to Ending a loop of content of LWP's get-function
The get function returns a scalar, and according to the documentation for LWP::Simple, you can check for success with defined instead of "while". Something like this (untested):
use warnings; use strict; use LWP::Simple; my ($html, $url); my $count = 0; $html = get("http://localhost:8080/html.htm"); die "Couldn't fetch page." unless defined $html; if ($html =~ m{<(a class=\"smallV110\" href=\"/)(.*?)\">} ) { $url = $2; print "$url\n"; $count++; print "$count\n"; } else { die "couldn't match"; }
|
|---|