#!/usr/bin/perl -w use warnings; use strict; use LWP::Simple; my ($html, $url); my $count = 0; my @urls = ( "http://localhost:8080/html.htm", ); for my $url (@urls) { my $html = get($url) or die "Couldn't fetch page."; $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"; } #### #!/usr/bin/perl -w use warnings; use strict; use LWP::Simple; my ($html, $url); my $count = 0; my $new_url; my @urls = ( "http://localhost:8080/html.htm", ); while (@urls) { my $url = shift(@urls); my $html = get($url) or die "Couldn't fetch page."; $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"; push @urls, $new_url; # or @new_urls }