I had been using flat files for some time and thought nothing about mixing code and content in all my scripts. Thanks to the people of this community, I've recently switched to a proper database and have begun to use a templating system. It's beginning to get exciting again...

On flat files perl cgi and flat textfile

I had been happy using flat files for storing data in web-based applications. Never mind the long hours spent on coding to perform ADD, UPDATE and DELETE. And never mind the fact that there's a real possibility that the files can become corrupted especially when rat-race conditions arise. And a host of other problems.

I was reluctant to make the switch to a proper database for a number of reasons. First, the amount of data that needs to be stored is small. Second, I know nothing about databases, much less to use perl to interact with one. Finally, I was lazy to learn :)

Now that I've begun to explore a database system (MySQL), I'm beginning to discover how things which would have been a nightmare to do with flat files have become not just simple, but more importantly, enjoyable. I don't think I'll ever make an U-turn.

However, I must add that I've learnt perl (e.g. regex) through manipulating flat files :)

On HTML::Template pulling content from db - is it a good idea?

This must have been one of my latest prized discoveries. I'm now able to separate most of the code from the content. Not only that, I'm also encouraged to re-use a particular template as much as possible. For instance, I've a template that is used for forms with different number of fields formatted in a table.

On OO perl vs plain perl perl OO - to use or not to use

Although I've successfully experimented with simple OO code, I find myself still using plain perl i.e. using method calls ( method($var) vs $result = $obj->method($var) ). Maybe OO perl is a little too abstract for a mere mortal like me. However, while I used to put every sub in a single main script, I now place related subs in modules and have the scripts call these subs using 'use'. It's so much cleaner now.

Conclusion

Without the help of this community, I would never have ventured out of the well and would still be thinking in terms of line after line of data and inspecting my code to tweak an html element or two.

Many thanks :)


In reply to On reflections by kiat

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.