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 noteon the Perl Authors Upload Server (PAUSE):

By con­ven­tion, the top-​level Localname­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 Localisn’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.

Your post must include a link to this post.

How does this work?
Write a response on your own website and include a link to this post. Then submit your response’s URL here. Your response may appear here after moderation. To update or remove it, edit or delete your original post and submit the same URL again. Learn more about Webmentions.