If you’re writ­ing Perl that’s nev­er going to the Comprehensive Perl Archive Network (CPAN), heed this little-​known note on the Perl Authors Upload Server (PAUSE):

By con­ven­tion, the top-​level Local name­space should nev­er con­flict with any­thing on CPAN. This allows you to be con­fi­dent that the name you choose under Local isn’t going to con­flict with any­thing from the out­side world.

PAUSE: On The Naming of Modules

So, Local::MyModule, Local::App::MyApp, what­ev­er. This is also good advice for bespoke appli­ca­tions and libraries (the so-​called DarkPAN) you’re devel­op­ing in-​house. The last thing you need is to acci­den­tal­ly bring in (per­haps via depen­den­cies) a mod­ule that gets loaded instead of yours.

2 thoughts on “Avoid CPAN conflicts in your personal Perl modules

  1. I find the best prac­tice to avoid con­flicts is do what is com­mon prac­tice in many places and use your own orga­ni­za­tion name etc as the main name­space. So if your com­pa­ny name is Foo Corp, then name all your own mod­ules in the FooCorp:: space. If your busi­ness has its own inter­net domain name then using some­thing that match­es that is prob­a­bly best. This is com­mon prac­tice in the Java world and maybe oth­er communities.

    • It gets tricky if your orga­ni­za­tion also has a pub­lic API or ser­vice, or oth­er­wise has some­thing that a CPAN author might want to inter­face with.

Comments are closed.