for(my $x = 0; $x < @links; $x++) { $webcrawler->get($links[$x]); my @more_links = map { $_->[0] } $webcrawler->links; # get Links @more_links = map { URI->new_abs( $_, $base_url ) } @more_links; @more_links = map { /^$base_url/ ? $_ : () } @more_links; # Add the filtered links from the more_links array to the links array push(@links,@more_links); #Finally, recursively go through the array and remove URL's that appear twice or more @links = do { my %z; grep { !$z{$_}++ } @links }; }