Search code examples
perlperl-module

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.

Solution

  • 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.