DRY (Don't Repeat Yourself)

Ovid on 2003-08-19T17:26:25

I have an idea for a one day class that I want to teach, so I sat down to write the sample code for it.

h2xs -AX -n Homepage::Manager
cd Homepage/Manager
rm t/1.t
cp ~/projects/common/t/base.t t/manager.t
cp ~/projects/common/t/grind t/
cp ~/projects/common/reload .

Then, I have to go in and do some standard editing to the basic test script, MANIFEST and Makefile.PL. In other words, after using h2xs to create my stub module, there are several tasks that I perform every time I start a project. While I've already hacked h2xs to use my email address and basic POD standards, when I get home tonight, I'm going to hack it to always set up my development environment just the way I like it. I'm tired of spending an extra ten minutes customizing things every time. Why didn't I think of this before?


NEVER BEGIN WITH H2XS!

schwern on 2003-08-19T21:00:09

See the light as I did. If you're not using XS, h2xs is just baggage. Write a little script to do:

cd /path/to/your/devel/dir
mkdir Some-Module
cd Some-Module
mkdir -p lib/Some/
cp /path/to/templates/Module.pm lib/Some/Module.pm
perl -i -pe 's/Module::Template/Some::Module/g;' lib/Some/Module.pm
mkdir t
cp /path/to/templates/t/test.t t/Some-Module.t
perl -i -pe 's/Module::Template/Some::Module/g;' t/Some-Module.t
cp /path/to/templates/Makefile.PL
perl -i -pe 's/Module::Template/Some::Module/g;' Makefile.PL
perl Makefile.PL
make manifest
make realclean
cvs import -m "Skeleton of Some::Module" Some-Module schwern start
cd ..
rm -rf Some-Module
cvs co Some-Module

Re:NEVER BEGIN WITH H2XS!

Matts on 2003-08-19T21:32:44

Even if you're doing XS, h2xs is baggage. I've never created a single module where I used the XS code auto-written by h2xs. Just drop in a .xs file to the mix and it gets compiled automatically by ExtUtils::MakeMaker, so why bother.

Re:NEVER BEGIN WITH H2XS!

schwern on 2003-08-20T07:42:39

"Just drop in an [sic] xs file into the mix" is sort of like saying "Just rebuild your carburetor".

Re:NEVER BEGIN WITH H2XS!

Matts on 2003-08-20T12:09:26

True. And? :-)

Re:NEVER BEGIN WITH H2XS!

Ovid on 2003-08-20T14:23:47

That is so much cleaner and more maintainable. Thanks!