#!/usr/bin/perl -w # Get urls from result page use warnings; use strict; use LWP::Simple; my ($html, $url); my $count = 0; $html = get("http://localhost:8080/html.htm") or die "Couldn't fetch page."; while($html) # <- Problematic part.. { $html =~ m{<(a class=\"smallV110\" href=\"/)(.*?)\">} || die "couldn't match"; #match regexp and capture backreference to $2, or die with error $url = $2; print "$url\n"; $count++; print "$count\n"; }