Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

namespace clash : how do I rename my module safely

by gideondsouza (Pilgrim)
on Jan 31, 2013 at 09:10 UTC ( #1016260=perlquestion: print w/replies, xml ) Need Help??
gideondsouza has asked for the wisdom of the Perl Monks concerning the following question:

Forgive me dear monks, I made quite a blunder last night.

I uploaded a module, (with an underscore for the purpose of CPAN testers testing it). It's a API wrapper for stack exchange. There is already an old module wrapping an old version of the api.

Unfortunately I didn't strike me that I put mine with the same name and only changed the internal modules with a V2 (like Net::GitHub). Both mine and the older module are named Net::StackExchange

I'm really sorry about this, it's a pretty daft mistake and I want to rectify it quickly and correctly.

I found Module::Rename, will it allow me to rename my module safely and thoroughly? My module is named Net-StackExchange and the directory structure looks like this:

├── Changes
├── Makefile.PL
├── ignore.txt
├── lib
│   └── Net
│       ├── StackExchange
│       │   ├── V2
│       │   │   └──
│       │   │   └──
│       │   │   └──
│       │   │   └── ....
│       │   │   └── ....
│       │   └──
│       └──
└── t
    ├── 00-load.t
    ├── boilerplate.t
    ├── manifest.t
    ├── pod-coverage.t
    └── pod.t


  1. Will module rename suffice, where else do I need to change files in Makefile.PL?
  2. I was thinking of just renaming to Net::StackExchange2 Not sure how nice this is?

  • Comment on namespace clash : how do I rename my module safely

Replies are listed 'Best First'.
Re: namespace clash : how do I rename my module safely
by MidLifeXis (Monsignor) on Jan 31, 2013 at 14:14 UTC

    Is there any cleanup work that should be done on CPAN / PAUSE as well? Would a PAUSE 'Delete Files' be appropriate at this point? I don't know (why I am asking the question).


      Yes :) I did know I have to delete bad versions and I deleted v0.01 of my Dancer plugin, but is it practise to only keep the latest version on CPAN? I will then delete all my old dists

        I don't know that deleting old versions is necessary, especially if a backward-breaking incompatibility has been added. :-)


        I read a note somewhere on PAUSE about how "CPAN is getting large, please delete old versions - they will be on backpan" ( Cant seem to find it anywhere now ).

        I have also noticed that Google sometimes shows the older module above the later version - so its possible that a visitor from Google ends up on an older version of the module.

        I generally remove all old modules ( other than the previous one ) - The exception of course is when I stop providing backward compatibility.

        There seem to be other reasons for removing older versions which I don't really subscribe to.

Re: namespace clash : how do I rename my module safely
by Anonymous Monk on Jan 31, 2013 at 10:20 UTC

    Manually? I think this is what I would choose

      Do you mean I should rename them manually? I need to rename all files and one directory, and then only the name inside Anything I'm missing out on?

        The complete list ( of files and locations in each file ) could be prohibitively long.

        I have had to change module names a couple of times and I generally create a new module with the correct name and paste in the functions from my old module.

        If not the list of things to change will include the POD, README, first line of "Changes" ...

        Even after this you will have to edit all your tests and make sure examples in your POD reflect the change!

Re: namespace clash : how do I rename my module safely (grep -l)
by tye (Sage) on Jan 31, 2013 at 18:56 UTC

    Rename the files (then commit, IMHO, so the renaming is "obvious" in the repo) and then vim $( git grep -l StackExchange ). I think it'd take me less time to do that (by hand) then has been spent talking about it in this thread.

    As for renaming the files, I'd just use mvi to make that extra easy. Though the version I have posted there doesn't know about doing "git mv" instead of just "mv" (but that is 2 minute's of work to address). :)

    - tye        

      Yep. I just created a module with the new name and the copy-pasted the old code into it. I cleaned it up with a search and replace :) All done pretty quickly.

      I was just afraid about missing anything obvious or making a silly mistake.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1016260]
Front-paged by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2017-07-23 01:52 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (343 votes). Check out past polls.