Manual installation of Perl modules

Source: Internet
Author: User
Tags perl script

In other forums, a lot of the installation of Perl modules, in fact, sometimes very easy to install failure.

Especially on Windows, such as tools such as cpan,ppm can be used. At the command line

Enter CPAN, eject cpan>, and then enter install module name, such as I want to install Lwp::useragent::P roxyany

Input install Lwp::useragent::P Roxyany, but often there are mistakes, this way is very troublesome. So exit; go to PPM,

Input ppm is a toolbar that can eject ppm, but the chances of error are great, and the response is slow. How to do it.

The above module is used for proxy server settings, such as some sites, in the country is disabled, we can through a number of foreign proxy server,

This method is easier to access.

How to do it. Very simply, search proxyany on http://search.cpan.org, download lwp-useragent-proxyany-1.02.tar.gz,

After decompression, there are 8 files.

On the Web, if you are under Windows, you need to install Make.exe, put it into the System32 directory, and you can do it. Then make,

Then make test, some of the modules will be successful. But both of these methods failed in the module.

I found a very simple way, the above module means in the LWP directory, find the useragent subdirectory, and then in this subdirectory to find proxyany.pm files,

We can directly create the desired directory useragent in the appropriate location, and then copy the proxyany.pm here under this folder, then test the code to find that it can

was used. is not very convenient.

The code is as follows:

#! Perl #LWP:: useragent::P roxyany-a LWP useragent supports both http_proxy and IE PROXY use lwp::useragent::P roxyany; Open (PROXY, "<f:/freeproxy1.txt") or Die $!; #freeProxy1. txt file contains a list of proxy addresses such as 24.98.120.7:8085. My $ua = lwp::useragent::P roxyany->new; $ua->env_proxy; My $response = $ua->get (' http://www.ncbi.nlm.nih.gov/pubmed '); while (<PROXY>) {$proxy = $_. ""; $ua->set_proxy_by_name ($proxy); if ($response->is_success) {print " The valid IP proxy is: ". $_." /n "; Print $response->content; #or whatever}else{print "Invalid IP proxy is:". $_; # die $response->status_line;} $ua->set_proxy_by_name ("No"); # $ua->set_proxy_by_name ("24.98.120.7:8085"); # Print $response->content; # or set proxy by specified name close proxy;

You can change the address, you can use the agent online.

The above is to get the corresponding address of the source code, data capture.

The above Perl script, or imperfect, in fact, do not have to set the agent specifically, as long as there is $ua->env_proxy this sentence, indicating the use of agents, it seems that you can directly access, too convenient.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.