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.


In reply to Re: Development Directory Structure and Technique by beppu
in thread Development Directory Structure and Technique by ichimunki

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.