Coding 101

Jul 31st 2014

Coding 101 28

Perl: The Wonderful World of CPAN

The Comprehensive Perl Archive Network
Although the show is no longer in production, you can enjoy episodes from the TWiT Archives.
Category: Help & How To

The Code for today's show is availible at our: Github

Ivory Tower

Let's talk about CPAN - "The Comprehensive Perl Archive Network"

One of the greatest benefits of programing in a modern language like Perl is the fact that you can take advantage of the work of tens or hundreds of thousands (millions?) of other programmers. CPAN has more than 136k Perl modules that you can download and use without for free and without royalty. So let's figure out how to get a module from CPAN

  1. Drop into the Command Line (or Terminal)
  2. Type: "perl - MCPAN -e shell"
    • If you've never used CPAN before, you MAY get a message saying that it's downloading all the necessary packaged and repositories to make CPAN work.
    • Let it download and install all the necessary packages
    • Once it's done, you'll get a "cpan>" prompt. Now let's search for some modules!
    • I'm going to look for LWP modules
    • "LWP" is short for "Library for WWW in Perl"
    • It's a set of very popular modules that allow you to access data on the World Wide Web.
  3. Type: "i /LWP::/"
    • This will search for all LWP modules
    • "i" will invoke a search
    • /LWP is the argument for the search :: "/" tells it to look for ALL LWP modules
  4. Install the Module!
    • "install (name of module)
    • In our instance, I want to install the module called "LWP::UserAgent::POE"
    • So I type: "install LWP:UserAgent:POE"
    • Perl will automatically download the module, unzip it, install the package.
    • Let it do it's thing... and you're ready to use the module!
    • If you go to your Perl folder, you should be able to find the files that were just installed
    • C:\Perl64\cpan\build\

Get in Touch With Us!

Bandwidth for Coding 101 is provided by CacheFly.