Keep It Simple, Stupid | |
PerlMonks |
Re: CGI App need directionby davido (Cardinal) |
on Oct 19, 2012 at 23:30 UTC ( [id://1000069]=note: print w/replies, xml ) | Need Help?? |
This can be trivial as a Mojolicious "lite-app". Don't forget to handle file locking, and be sure to deal gracefully with problems such as failure to open the message file. The whole thing including the rendering template could be done without being golfy in around 78 lines of code (I know because that's what I came up with when I tried it myself), about 1/3rd of which is auto-generated for you when you generate a lite app with the "$ mojo generate lite-app" command. The template that you start with, plus the Mojolicious::Lite POD will lead you along the right path. What's probably not quite so trivial is getting over that initial hump of learning how it all works. But really, the documentation for http://mojolicio.us is pretty good, and in particular, if you focus on creating a "lite-app", your first successful attempt might take an hour or two to work through. And then the next time you have to do something similar, it will take a few minutes to toss together. Whether you go the Mojolicious route, or Dancer, or even CGI, the first step will be reading the documentation. At that point you'll be able to ask a question that addresses specific areas where you need clarification, rather than "I need the whole thing." Here is an example Mojolicious application that does basically what you're describing. You might look it over to get some ideas. It doesn't provide a strong separation of concerns between the controller and the data model, but in such a trivial case enhancing the separation might actually add complexity. FWIW, Mojolicious has a CGI compatibility mode, so you can use code very similar to this in your solution.
As a stand-alone application, run it as "./myapp.pl daemon". It shouldn't require any special handling in a CGI environment so long as your server is configured as it would be for any other CGI script, although if you're still using CGI you ought to consider persistent processes instead. Dave
In Section
Seekers of Perl Wisdom
|
|