Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (1)
As of 2024-04-19 00:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found