I'm considering porting an existing, moderately complex set of cgi scripts to CGI::Application. I'm new to it, however, and its not at all clear what the best structure of is. Its about 15 scripts, maybe 20 run modes. Not what you'd call large at all, really, but there is no way I'm putting it all in one module. (much of the code is already in db and other modules, but I'd still have a monster).
This is obviously a topic thats been covered before, so any links welcome. I've seen the wiki and I've trawled through the mailing list, and, of course, Super Search. But I've probably missed lots.
I see three options, and I'm not crazy about any:
- Convert, roughly, each script to a different cgi app, using a common superclass. Each would have their own setup and run modes. However this leaves me with lots of little stub scripts in place of the originals, which differ only in the class they use. Ugly.
- One application, one instantiating script. The application is a big run mode dispatcher that finds the methods in several classes, but doesn't implement any in the main package. Hide much of the run mode information in PATH_INFO to make the urls a bit prettier: admin.pl/foo/bar/baz gets mapped to Foo::Bar::baz. But I do like per-page setup methods, which this loses.
- Hybrid of the above. Separate applications, but a single dispatching script (no need to use CGI::Application) that reads the PATH_INFO and invokes the appropriate application.
thanks, qq
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.