print "Enter your search query: "; my $search = ; chomp($search); my $google_results; my @urls = qq("http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=50&sa=N", "http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=100&sa=N", "http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=150&sa=N", "http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=200&sa=N", "http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=250&sa=N", "http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=300&sa=N", "http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=350&sa=N", "http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=400&sa=N", "http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=450&sa=N", "http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=500&sa=N", "http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=550&sa=N", "http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=600&sa=N", "http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=700&sa=N", "http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=750&sa=N", "http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=800&sa=N", "http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=850&sa=N", "http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=900&sa=N", "http://www.google.com/search?q=$search&num=50&hl=en&lr=&safe=off&start=950&sa=N", ); foreach my $url (@urls) { my $response = $ua->get( $url ); unless ($response->is_success) { print $response->status_line, $/; next; } $google_results = $response->content; &parser; } sub parser { my @links_wanted; my @links_found; my $parser = HTML::TokeParser->new( \$google_results ); while ( my $token = $parser->get_tag( 'a' ) ) { my $url = $token->[ 1 ]{ href }; next unless $url =~ m{^https?://}; push @links_found, $url; }