简体   繁体   中英

How to install perl module and include in Perl script?

I am new to the Perl. I've downloaded HTML-TreeBuilder-XPath-0.14.tar.gz I want to know how to install it.

I am using Windows.

How to include this in my perl script?

I've opened cpan using run command and installed HTML-TreeBuilder-XPath-0.14 using the command install HTML-TreeBuilder-XPath-0.14 , but I got the following error:

Writing C:\Perl\cpan\Metadata
Warning: Cannot install HTML-TreeBuilder-XPath-0.14, don't know what it is.
Try the command

    i /HTML-TreeBuilder-XPath-0.14/

to find objects with matching identifiers.

You need to give the module name , not the distribution name:

install HTML::TreeBuilder::XPath

You don't need to download the distribution first, cpan will do that for you.

The easiest way that i found to install any perl module is :

Step 1 : open your os terminal

Step 2 : change path to bin folder path. example(windows) -> cd C:\\Strawberry\\perl\\bin

Step 3 : now run a command : perl cpan

Step 4 : type below command to check installation is working or not. example(windows) -> install App::cpanminus

Step 5 : now for installing any perl module do like this(for Convert::EBCDIC module) : example(windows) -> install Convert::EBCDIC

Awesome, you are done!!

Its easiest if you just run the CPAN shell from your machine ( type "cpan" ) and then just type "install HTML-TreeBuilder-XPath-0.14" from that shell.

It will go off and find the module and take care of the installation.

To then use it in your script just add:

use HTML-TreeBuilder-XPath-0.14;

before you make use of it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM