in reply to question regarding small CGI based application

You are on the right track. Stick to it, accept that it will take a bit of work to get into things, but you will be saving lots of work in the long run.

First off, don't worry about having lots of run modes. That's normal. You want one for every screen. These run modes will be very thin though, because you will call other subroutines to do all the work.

Second, in your example code, in prerun, you don't need to determine the runmode (that's done for you).

You might also write the entire login/check credentials as a seperate related CGI::App. This is good for later code reuse on different projects. You can call this from your other application. In general, you want to have all the runmodes for one generalized webapp bundled together. An example I wrote is a "contact" webapp that has screens for new/edit/delete of "contacts" which are stored in a DB. Very reusable across projects.

It is a matter of taste, but I keep all the run modes in one file. The subroutines that "do stuff", ( my model of the Model-View-Controller paradigm ) go in another module.

Lastly, CGI::App used with CGI::Application:ValidateRM (which uses Data::Validate) allows for really user-friendly and programmer friendly HTML form validation and error handling.

Keep us apprised of your progress. I am pleased to share ideas here on perlmonks.

cheers

-------------------------------------
Nothing is too wonderful to be true
-- Michael Faraday

  • Comment on Re: question regarding small CGI based application