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

I have a set of modules I had written originally as part of a standalone project, thus they all have root-level package/module names (or hierarchies starting at root level) like "deck" and "player" (it's a blackjack-related project). They refer to each-other, they operate as a system.

Now I've decided to submit the set of modules to CPAN. It's therefore time to move the set of modules from root-level to be sub-levels of my new namespace, Games::Tournament::Blackjack.

( For the record, yes, I did post to modules@perl.org before deciding I'm sure about the name. )

It's not a huge set of modules, surely less than a dozen files, but given the repeatable nature of the task of relocating a set of modules from one common root namespace to a new root namespace, it seems preferable for it to be a job for a perl program or module. I want to make sure to:

1 - rename the files and put them in the appropriate stack of directories
2 - change all cross-references, including fully-qualified variable names referencing other classes
3 - change the package X; declaration
4 - do a fulltext search for the full XX::YY::ZZ of the common original namespace (if any) and replace with the new name, to cover comments.

I realize that I won't be able to cover extreme cases, such as someone eval'ing an expression that builds to the package name..

Any chance this problem has been tackled and documented / encapsulated before?

Replies are listed 'Best First'.
Re: Tool to Relocate Module Namespaces
by saintmike (Vicar) on Jan 28, 2005 at 06:31 UTC
    Sounds like a fabulous idea for a new module: Module::Rename (yet to be written) ...
      That did occur to me, and I did search CPAN for similar, no luck. I might end up making one (no promises:), but I thought it would be useful to ask here first.