in reply to Building Good Modules

Yes, I concur with talexb that option 2 is the way to go.

Start a project directory and make subdirs:

lib/ t/ bin/

Put your modules in lib/ using a top-level dir for the top level part of your namespace (if you one day distribute to CPAN you will want a distro name under PostScript and not put your modules directly under the top level) and maybe using subdirs for segments of your desired namespace:
/lib/YOUR_DISTRO_NAME/PSjoin.pm /lib/YOUR_DISTRO_NAME/PS2png.pm /lib/YOUR_DISTRO_NAME/PStopdf.pm /lib/YOUR_DISTRO_NAME/Utils/Frobnicate.pm
and use them like
use YOUR_DISTRO_NAME::PSjoin; use YOUR_DISTRO_NAME::Utils::Frobnicate;

Add that whole directory tree to a version control system like git. Do it first! Then write tests in t/ for all the things. Maybe use subdirs there for the different modules, maybe it's by functionality, maybe both: that's up to you.

Then when you want to build a distribution in the future your files will be in the proper structure. You don't have to worry about such packaging tools now, but preparing for them is wise.

Hope this helps!


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: Building Good Modules
by John N8UR (Novice) on Feb 13, 2019 at 02:56 UTC
    Thank you Alex and 1nickt! You've confirmed what I was hoping was the right way to do it. I'm already part way down the road -- I used the module-starter tool to set up the directory structure (at the moment, for the separate trees, but I'll merge them), and I use github.

    If I have multiple .pm files in the bin/ directory, will the normal sequence of perl makefile.PL; make ; etc. catch all the files, or do I need to manually edit the makefile to have it find the multiple .pm files? Thanks again!

      If I have multiple .pm files in the bin/ directory

      Don't put .pm files in the bin/ directory - put them in the lib/ directory instead. Then yes, they should be found automatically by the build and test process.

        I'm sorry, I mistyped. My brain knew it was lib/ but my fingers didn't.