Avoid CPAN conflicts in your personal Perl modules

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.


Discover more from The Phoenix Trap

Subscribe to get the latest posts sent to your email.

Mark Gardner Avatar

Hi, I’m Mark.

Hi, I’m Mark Gard­ner, and this is my personal blog. I show software developers how to level up by building production-ready things that work. Clear code, real projects, lessons learned.

Comments

2 responses to “Avoid CPAN conflicts in your personal Perl modules”

  1. Darren Duncan Avatar
    Darren Duncan

    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.

    1. Mark Gardner Avatar

      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.

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)