There was a discussion a few months ago about a proposed change in the [cpan://module] shortcut to link to distributions rather than module search results, which was (rightly) rejected as breaking links on existing nodes.

At the cost of flogging an expired quadruped, I'd like to propose a variation on that suggestion which (hopefully) won't break existing links, while adding the capability mirod was requesting.

The proposal: CPAN links which contain a hyphen should be converted to http://search.cpan.org/dist/ form. To allow linking to single-word distributions, such links should also have any trailing hyphens removed.

Module names can't contain hyphens, so there shouldn't be any existing nodes that would trigger this behavior; all past and future posts using the existing syntax will be unaffected.

This seems like a straightforward change, but I haven't poked through the monastery code base to see whether there would be more complications than expected...

Update: if the regex is general enough, this also lets you link to specific files in the distribution:

  • Comment on A Modest Proposal for [cpan://module] Shortcuts

Replies are listed 'Best First'.
Re: A Modest Proposal for [cpan://module] Shortcuts
by davido (Cardinal) on Apr 18, 2004 at 08:40 UTC
    Rather than overloading [cpan://.....], how about a new tag instead that links to the distribution: [distro://.....] ... or ... [module://....]?

    That would be easier for me to remember than trying to remember to place hyphens in my links.


    Dave

      Rather than overloading [cpan://.....], how about a new tag instead that links to the distribution: [distro://.....] ...

      That would be fine; I'd be glad to take whichever is easier for the gods to implement...

Re: A Modest Proposal for [cpan://module] Shortcuts
by ysth (Canon) on Apr 19, 2004 at 02:01 UTC
    Rather than introduce this kind of DWIMery, I'd like to see the existing cpan:// preserved as a search link and new types added:
    • cpandist://Distribution-Foo -> http://search.cpan.org/dist/Distribution-Foo and
    • cpandoc://Module::Foo -> http://search.cpan.org/perldoc/Module::Foo
A new linktype for CPAN: [dist://]
by bart (Canon) on Jun 25, 2005 at 09:44 UTC
    I'm happy to announce that I've created a patch, which demerphq applied, that provides a new linktype, [dist://module distro], offering the requested functionality. The basic trick is that search.cpan.org provides a family of URLs which you can use to search for distributions, under the http://search.cpan.org/dist/ root. For example:

    As an extra help, I've provided a basic conversion of (double) colons and spaces into a single hyphen, so you can use a more human-friendly link, which still creates the proper link for the common cases. For example: [dist://Class::DBI 0.95] which links to Class::DBI 0.95. I think that should work nicely.

    p.s. Did I mention my previous recently added linktype already? [module://module name] (or [mod://module name]) links directly into the module docs of the most recent version of a module. For example: [module://Class::DBI] which yields Class::DBI. It is very strict about your spelling/capitalisation, though. Thank goodness [dist://module name] is more forgiving.

      Thanks!
Re: A Modest Proposal for [cpan://module] Shortcuts
by duff (Parson) on Apr 18, 2004 at 01:40 UTC
Re: A Modest Proposal for [cpan://module] Shortcuts
by sintadil (Pilgrim) on Sep 04, 2004 at 03:27 UTC

    I definitely agree with the idea, being that I just found this node before posting the same exact request. I disagree with your link choice, though. I'd personally use one of the already-suggested URLs. Other than that, this is definitely worthy of a ++, which I will be giving once I have more votes.