in reply to Re: Re: Pushing unique items onto an array
in thread Pushing unique items onto an array
If I'm guessing right about what you are trying to do, here's some code that might help. You'll have to provide the fetch_urls() sub and you should also think about limiting the depth and/or breadth of your search.
Untested...
my %seen; my @urls; my $root_url = 'http://url.example.com/'; $seen{$root_url}++; push @urls, $root_url; while ($root_url = shift @urls) { for my $url ( fetch_urls($root_url) ) { $url =~ s/#.*$//; push @urls, $url unless $seen{$url}; $seen{$url}++; } }
-sauoq "My two cents aren't worth a dime.";
|
|---|