Can someone please help me with this. i am new to using modules and trying to run this script. but it displays the following message:
Can't connect to www.search.cpan.org:80 (Bad hostname 'www.search.cpan.org')
here is the script
Expand|Select|Wrap|Line Numbers
- # Create a user agent object
- use LWP::UserAgent;
- use HTTP::Headers;
- $ua = LWP::UserAgent->new;
- my $newagent = 'search_rfc/1.0('.$ua->agent.')';
- $ua->agent($newagent);
- # Create a request
- my $req = HTTP::Request->new(POST =>'http://www.search.cpan.org/search');
- $req->content_type('application/x-www-form-urlencoded');
- $req->content('query=libwww-perl&mode=dist' );
- # Pass request to the user agent and get a response back
- my $res = $ua->request($req);
- # Check the outcome of the response
- die $res->message unless $res->is_success;
- print "echo $res->as_string\n";
john