My first reaction to this was that Dancer would be overkill for such a small task. I've been working with Dancer lately and like it a lot, but using a framework for what amounts to a 10-line CGI? But then I reconsidered and tried it. I can't say it saved me any time or lines of code, but it did keep things cleaner and more organized. The rule-based structure of Dancer makes it very easy to see what URI is involved. Keeping the code separate from the HTML makes it easier to write one and then the other, without the back-and-forth in my head that I tend to do when writing CGI with HTML embedded in it (as functions like h1() or as strings), which is nice even for a small task.

And since I already had Dancer running and configured on this site, I could just add the rule and the template, without worrying about the path to the perl executable, or whether my CGI needed to go in the cgi-bin directory or have a particular extension, or any of that other fun stuff that made installing CGI scripts too difficult for most newbies. And if I want to expand on this utility later, to make it more robust by adding more logging and error checking, or perhaps to save the lookups in a database cache, the payoff from using Dancer in the first place will only grow as the complexity of the thing increases.

So I'm sold: Dancer is even good for small stuff. I probably still won't use it when I need to write a one-line script to run a one-time command on a server where I don't have shell access, like `rm annoying_file_owned_by_webserver_that_I_can't_remove_by_FTP`; those will still go in quick CGIs (or PHP). But I think everything else will be done in Dancer if it can be.

Aaron B.
My Woefully Neglected Blog, where I occasionally mention Perl.


In reply to Re^2: Creating a web application in Perl by aaron_baugher
in thread Creating a web application in Perl by Anonymous Monk

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.