http://www.perlmonks.org?node_id=1189330

rachard11 has asked for the wisdom of the Perl Monks concerning the following question:

Why does the following code result in the error message: "Error GETing http://www.securities.stanford.edu/filings-case.html?id=100992: Can't connect to www.securities.stanford.edu:80 (Bad hostname) at (reference to the last line in the code below)? Based on related posts, this problem should either be fixable by modifying the code below or by adjusting my connection (DNS) settings in my computer, but I've not been able to figure out the solution exactly. I'm using Windows 7, Chrome is my default browser, I can successfully ping securities.stanford.edu from the command prompt.

#!/usr/bin/perl use strict; use warnings; use WWW::Mechanize ; my $mech = WWW::Mechanize->new(); foreach my $line (100982..106146) { next if 0.99 > rand ; print "Now processing $line \n" ; my $get_file = "http://www.securities.stanford.edu/filings-case.ht +ml?id=".$line; my $filename = "file_".$line ; open OUT, ">$filename" or die $!; print "file $filename \n"; $mech->get($get_file) ;