Earlier in the evening, converter, who was working on his extremely handy perldoc IRC bot, had an idea: that it would be pretty handy for the bot to have a searchable list of all cpan modules with their descriptions. Well, CPAN, doesn't exactly have a list of modules, it has a catagorized list of modules, known as theModule Long List. There is also a text-only (but much harder to parse) version. With the wonderousHTML::TokeParser, a script was quickly written that extracts the module links and their corresponding descriptions. Note that this script may seem slow; it is because CPAN isn't the fastest of servers. Just be patient :)

#!perl -w use HTML::TokeParser; use LWP::Simple; use strict; ## set marker definintions my $content = get("http://www.cpan.org/modules/00modlist.long.html"); my $parse = HTML::TokeParser->new(\$content); my @module; my @links; while (my $token = $parse->get_tag("a")) { my $url = $token->[1]{href} || ""; my $text = $parse->get_trimmed_text("/a"); if (($url =~ /module=/i) && $text) { push @links, quotemeta(qq(<a href="$url">$text</a>)); my $header = quotemeta(qq(http://search.cpan.org/searc +h?module=)); $url =~ s/^$header(.*?)/$1/i; push @module, $url; } } my @descs; foreach my $link (@links) { my ($desc) = $content =~ /$link(.*?)\Q<\E/im; push @descs, $desc; }

In reply to Grab a list of all modules on CPAN + their descriptions by jryan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.