What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 131 Stack Exchange communities.

How should Perl CPAN modules be linked to in the text of answers on StackOverflow.com such that the people who follow the link (perhaps in the distant future) will always be taken to the latest stable version of that module?

Using a URL that always shows the latest stable version is important not only to ensure that everyone benefits from bug fixes, but also because old versions may actually be (and often are) deleted from CPAN.

share|improve this question

migrated from stackoverflow.com Aug 24 '09 at 22:02

This question came from our site for professional and enthusiast programmers.

5 Answers 5

Links to CPAN module distributions should be in this form:

http://search.cpan.org/dist/<module-distribution-name>/

where <module-distribution-name> should be replaced with the hyphen-separated module distribution name. Example:

http://search.cpan.org/dist/XML-Parser/

And now an example inline: XML::Parser.

Links to individual modules should be in this form:

http://search.cpan.org/perldoc?<module-name>
http://search.cpan.org/perldoc/<module-name>

where <module-name> should be replaced with the individual module name. Example:

http://search.cpan.org/perldoc?Rose::HTML::Form::Field

Inline example: Rose::HTML::Form::Field.

share|improve this answer

On another note, for short-hand linking to absolutely any Perl-related resource at all, you should take a look at p3rl.org.

This is a redirector in the style of URL shortening services that was created by Juerd because he was envious of how easy php.net made it to link to PHP resources during IRC discussions. But it goes a good deal above and beyond the features offered by its model – you can link to any one Perl function, the Perl docs, CPAN modules, or (using commas) even link to several of those at once. There are several predefined special links, and groups of links. The site also offers a pastebin.

Very handy for most of your Perl linking needs.

share|improve this answer

If you have the name of a Perl module, such as Net::MAC, you can tack it on to the end of the following URL stub:

http://search.cpan.org/perldoc?

So using the above example, this would become:

http://search.cpan.org/perldoc?Net::MAC

There are two advantages to using this method over others:

  1. You are taken straight to the manual page for the latest version of that module
  2. No need to substitute double-colons for hyphens

This second point is crucial if you want to set up a quick search in the Firefox web browser. For instance you could type "cpan Net::MAC" in the address/awesome bar and Firefox would be able to construct the URL as above.

Finally, here is a real link using the above example: Net::MAC

share|improve this answer
    
The disadvantage, however, is that people don't know what to do to not be on that page. That is, it's hard to tell what to do next. That's not a huge deal, but it's the reason I don't use this form. –  brian d foy May 4 '10 at 21:48

John Siracusa wrote:

I think module distributions will most frequently be the unit of recommendation.

True, but the module’s documentation is usually more immediately useful than an overview over the contents of its distribution, and the distribution is just one click away from the documentation page. Also, much of the time you do not want to download tarballs via search.cpan anyway – you just want to browse docs and then use your preferred package manager to install, whether it be CPAN.pm, Aptitude, ports, pkgsrc, PPM, or whatever.

That said, some larger distributions, eg. Moose, come with several different documentation pages, each of which will be useful to different parts of the audience, so in that case it seems preferable to link to the distribution and let each user pick whichever entry point they prefer, instead of linking to a specific one.

share|improve this answer

There's actually a distinction here that was not made clear in the original question. When linking to a module distribution on CPAN, you should use the http://search.cpan.org/dist/XXX/ form. When linking to an individual module within a distribution, use the http://search.cpan.org/perldoc?XXX form.

When recommending things from CPAN on StackOverflow, I think module distributions will most frequently be the unit of recommendation. After all, you don't download an individual ".pm" file from CPAN. What you download from CPAN are whole module distributions.

Nevertheless, it's good to know how to do both.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .