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.

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.

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:

You are taken straight to the manual page for the latest version of that module

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.

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 foyMay 4 '10 at 21:48

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.

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.