When I code in perl, I try to keep CPAN in mind.
I'm writing a module called Embedix::DB and the
directory structure looks like this:
.
|-- Changes
|-- DB
| |-- CML2.pm
| |-- ECD.pm
| `-- Pg.pm
|-- DB.pm
|-- MANIFEST
|-- MANIFEST.SKIP
|-- Makefile.PL
|-- README
|-- bin
| `-- ebx
|-- htdocs
| |-- backend_api.pod
| `-- index.html
|-- sql
| |-- pg_reset.sql
| `-- pg_schema.sql
`-- t
|-- 00_pg.t
`-- data
`-- textutils.ecd
This is a structure that's similar to a lot of what
you'll find in CPAN, and I find that it works pretty
well.
The module installation framework provided by
the modules in the ExtUtils::* namespace is a huge
advantage Perl has over other languages. I think
it's awesome that practically every module in CPAN
can be installed by doing:
perl Makefile.PL
make
make test
make install
That kicks ass. You can write your Makefile.PL such
that module dependencies are checked for. You can also
have make install put executable scripts in /usr/bin (or
whatever $PREFIX/bin happens to be for your perl installation).
As an example, here's my Makefile.PL for Embedix::DB:
use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'Embedix::DB',
'VERSION_FROM' => 'DB.pm',
'ABSTRACT_FROM' => 'DB.pm',
'EXE_FILES' => qw(bin/ebx) ,
'PREREQ_PM' => {
'Embedix::ECD' => 0,
'DBI' => 0,
'Pod::Usage' => 0,
'Test' => 0,
},
);
PREREQ_PM is for specifying module dependencies, and
EXE_FILES is for specifying a list of scripts to install.
EXE_FILES doesn't work too well for webapps, but you're pretty
much on your own, when it comes to installing those, because
everyone installs Apache differently.
You know what else? I love having a standardized testing
framework, too. I've even started to like writing tests
for my modules, because it's kind of fun to run "make test"
and watch it succeed or see how much time it takes.
I'm really surprised the Python or Ruby people haven't
tried to copy this aspect of Perl, yet. It would really
help them out.
Well, that's how I develop. This style works for me.
|