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

Hi

I started a new Perl project with Module::Starter and added a bunch of "sub-modules" in the distribution.

modules      => [ module names ], # modules to create in distro

Now I realize that I have to redesign the distribution (rename some modules, add new ones, get rid of others)

Is there a canonical way of doing it after already writing lots of code?

My best guess at the moment is to rerun Module::Starter and copy the already crafted code when renaming...

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Replies are listed 'Best First'.
Re: Redesigning distribution with Module::Starter
by Corion (Patriarch) on Aug 23, 2018 at 10:44 UTC

    I think Module::Starter is only for starting a distribution, not for maintaining things in the longer run.

    Usually when splitting up a module, I save the file under both new names and then delete stuff that does not belong in the respective file.

    You can also run Module::Starter in a different directory to create a new skeleton for your distribution, but then you will have to copy over and merge files. I don't find the Perl "boilerplate" (if any) to be that tedious, but maybe some text editor could help there :)))

      > I don't find the Perl "boilerplate" (if any) to be that tedious,

      There is plenty. Like module-names being hardcoded into tests.

      FWIW: There are other modules which try to solve this issue.

      like Module::Starter::AddModule

      I think I will fall back to a more dynamic approach, using pseudo.t files in my test directory automating the updates whenever I run prove.

      Things like updating .pod files and README by templates and updating the VERSION number. And updating the manifest and so on.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

        I think all those maintenance tasks are outside of what Module::Starter purports to do.

        Just as an example, here's how I do these things:

        • Test files don't need to know the module names besides their functionality, so changing the module name/splitting a module name will obviously also need editing the test. But most likely this also comes with a change in the API, so something more needs to change anyway.
        • If a test file really needs to know about the name of the (main) module, I have that test load my Makefile.PL, which can provide that information through a function.
        • I don't know why updating POD files would be a problem, but then I only use POD files for documentation that has no additional code. All other documentation lives in the .pm file itself and gets updated by me writing that.
        • Updating the version number of a distribution is a job for perl-reversion in Perl::Version.
        • Updating the MANIFEST file is done by make manifest.
        • Updating the META.* files is done by make distmeta.

        There are other approaches, for example I don't know how Module::Build-based distributions manage these files.

        There are Dist::Zilla and Dist::Minilla, which also allow you to manage a distribution, but I dislike them as for supplying a patch or running the test suite on a Git checkout of such a module, you also need to install the same distribution builder and all the plugins that the author has used for this distribution.

Re: Redesigning distribution with Module::Starter
by TheloniusMonk (Sexton) on Aug 23, 2018 at 09:47 UTC
    I'd start by using .h file(s) to rename stuff (CPP has enough power) and see how far that gets.