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

I am working on a CGI database interface for work. So far I have only really created one file scripts. Now that I am writing something longer, I will have to organize my code into modules for specific tasks. Is there a standardized best practice for arranging your files for a larger application? Would anyone mind letting me know how they arrange their code? How about good places where I can find a good standard to work toward?

Thanks,

-Actualize

  • Comment on Is there a standardized directory structure for perl applications

Replies are listed 'Best First'.
Re: Is there a standardized directory structure for perl applications
by Joost (Canon) on Jul 17, 2008 at 20:40 UTC
    For CGI apps, I suggest you start by looking at CGI::Application. It's simple, light-weight and gives you a fairly good structure for building your own apps on top of it.

    In general, you want to structure your modules so that related code is in the same, or related modules, and unrelated code is separated into other modules. For instance, you may want to have "generic" HTML generating / templating code in one module, and have database-access code in another. Once you do that, you should also take a look at CPAN, since there are many many modules there that help you with these subproblems.

    Also see this article I wrote on MVC for the web - at least as a short introduction to a common way of separating concerns in web apps.

      This is exactly what I am looking for. Your MVC article gives me a quick overview of where I want to put my code and why. thank you so much

      -Actualize

Re: Is there a standardized directory structure for perl applications
by bradcathey (Prior) on Jul 17, 2008 at 22:07 UTC

    actualize,

    This is not a plug for my node, but I just happened to post this the other day. It is primarily about CGI::Application, but does talk about a bit about directory and file structure. See the comments and a revised directory in a reply.

    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
      Brad,

      I saw your node yesterday. The diagram gives a great example of the kind of directory structure I am looking for. Actually, your tutorial got me to start thinking about what kind of design philosophy I should work with when I am creating an application. Subsequently it what inspired this post.

      Anyway, you're post in reference to your Tutorial got my vote right away. I will definitely be referencing your tutorial while I am working on my app.

      Thanks, for your help

      -Actualize

        Great! Fire away with your questions. I'll try to keep a watch out for them.

        —Brad
        "The important work of moving the world forward does not wait to be done by perfect men." George Eliot