EvdB has asked for the wisdom of the Perl Monks concerning the following question:

If I want to create some modules and install them on my own system in the proper places (ie /usr/local/lib/perl5/site_perl/5.8.2 etc) is there a name space that is reserved for this. I thought that My::* might be good for this but checking on CPAN got me worried.

What I want is a namespace fo my modules that I KNOW will never clash with anything off CPAN - is there such a thing?

--tidiness is the memory loss of environmental mnemonics

Replies are listed 'Best First'.
Re: Guaranteed unused namespace on CPAN
by idsfa (Vicar) on Dec 10, 2003 at 16:42 UTC

    Local::* is reserved for this purpose. From The Perl 5 Module List (Part 1, section 2.5):

    If developing modules for private internal or project specific use, that will never be released to the public, then you should ensure that their names will not clash with any future public module. You can do this either by using the reserved Local::* category or by using an underscore in the top level name like Foo_Corp::*.

    My parents just came back from a planet where the dominant life form had no
    bilateral symmetry, and all I got was this stupid F-Shirt.
      The second suggestion is violated by the standard distribution (AnyDBM_File, GDBM_File, NDBM_File, SDBM_File), although it could be argued they are just .pm files, and don't use class names with '::' in them. But a quick scan of the file sources/modules/02packages.details.txt.gz shows several name spaces that use an underscore in the first component. (CDB_File, DB_File, DWH_File, heavy_template).

      I think that in theory the way Perl and CPAN works is that it is very hard to make sure there are no name clashes. I think that practise has shown that there's not much of a problem.

      Abigail

Re: Guaranteed unused namespace on CPAN
by flyingmoose (Priest) on Dec 10, 2003 at 18:03 UTC

    To borrow something from java's convention (I'm not exactly fond of java, but ah well), you can use your organization or name to provide a very reasonable namespace.

    Certaintly there could be another FordMotorCompany::Gizmo and there may be another AlanSmithee::Gizmo, but they wouldn't be uploaded to CPAN.

    Java handles this as follows: com.ford.foo.bar.absurdly.long.package.namespace.Gizmo. Not too elegant, but the general idea is borrowable, methinks. They are using URL registration to represent ownership. In general, I don't like this, as it implies you have a URL to yourself. Not everyone does.

    For the more creative, pick some random nonsensical phrase that anyone would be too embarassed to use on CPAN. Such as ILoveFrisbeesAndMooses::Gizmo :)