my @urls = ( "http://localhost:8080/html.htm", ); for my $url (@urls) { my $html = get($url) or die "Couldn't fetch page."; $html =~ ... ... } #### my @urls = ( "http://localhost:8080/html.htm", ); while (@urls) { my $url = shift(@urls); my $html = get($url) or die "Couldn't fetch page."; $html =~ ... ... push @urls, $new_url; # or @new_urls ... }