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

Hello

I am trying to run this script. but it saying "500 Can't connect to twitter.com:80 (Bad hostname)"

LWP::Simple use LWP::UserAgent; use Net::SSL (); # From Crypt-SSLeay $Net::HTTPS::SSL_SOCKET_CLASS = "Net::SSL"; # Force use of Net::SSL $ENV{HTTP_PROXY} = 'http://defaultgatewayusedbymyPC:port'; $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; my $ua = LWP::UserAgent->new(); my $req = HTTP::Request->new('GET','http://twitter.com'); my $res = $ua->request($req); print $res->status_line;

actually I have to run perl script which access http and ftp but before that I am trying to find out which way proxy settings should be written.

But alas its not working. I have tried many ways, i think I am missing something

Please Help me

If possible please reply as early as possible

Replies are listed 'Best First'.
Re: proxy problwm LWP
by hdb (Monsignor) on May 16, 2015 at 16:50 UTC

    You can provide a proxy directly without resorting to environment variables:

    $ua->proxy(['http', 'ftp'], 'http://proxy.sn.no:8001/');

      hii

      but if don't provide encrionment variable and directly using the

       $ua->proxy(['http', 'ftp'], 'http://proxy.sn.no:8001/');

      then its saying

      "Can't call method "proxy" on an undefined value at trial_lwp.pl line 3."

        I suggest to use strict; and use warnings; and then have the "proxy" line after the "new" line for the user agent:

        my $ua = LWP::UserAgent->new(); $ua->proxy(['http', 'ftp'], 'http://proxy.sn.no:8001/');