in reply to Admin-ing a file?

I'm attempting to help based on the following assumptions:
  1. Your page is written as a CGI in Perl (just guessing by the fact that you're posting on PerlMonks
  2. Your flatfile is CSV or some other fairly simple format
  3. You're not asking how to design your database
If any of the above are false, let us know, and we'll probably be able to help. In essense, what you should be doing to prepare for when MySQL is available is writing wrappers to encompass the common operations on your data. For your guestbook example, perhaps you'll want to create functions like: Initially, of course, implement them on your flatfile, but start writing (and testing) SQL versions that work with experimental versions of what the tables will be for your guestbook. When the database is available, ideally your SQL versions of the functions will be ready to go, and after you import the existing data into the database, there won't be any bumps. I hope this answers your question.

Replies are listed 'Best First'.
Re: Re: Admin-ing a file?
by stonecolddevin (Parson) on Apr 24, 2003 at 03:46 UTC
    Ooh, I guess they don't email you when you get a reply here. Sorry for the late reply; To answer some of the questions of Improv, you nailed all three of those. I am using a .dat file, like a csv file I am assuming, I'm not doing this version in mysql, and I am using p Yeerl no doubt. Ok, here is an example of my .dat file:
    <!--START:--> <table width=500 border=0 cellpadding=5 cellspacing=0><tr><td>Signed o +n:&nbsp;April 23, 2003</td></tr><tr><td>Name:Devin</td></tr><tr><td>E +mail:&nbsp; <a href='mailto:'puckchewer@cs.com>puckchewer@cs.com</a>< +/td></tr><tr><td>Country:USA</td><tr><td>State/Province/Territory:&nb +sp;Colorado</td></tr><tr><td>City:&nbsp;Loveland</td></tr><tr><td>Sit +e rating:&nbsp;10</td></tr><tr><td>Comments:<br>Testing my entry for +the second time to see if the buffer turned off.</tr><tr><td></table> <!--END:--><!--START:--> <table width=500 border=0 cellpadding=5 cellspacing=0><tr><td>Signed o +n:&nbsp;April 23, 2003</td></tr><tr><td>Name:Devin</td></tr><tr><td>E +mail:&nbsp; <a href='mailto:'puckchewer@cs.com>puckchewer@cs.com</a>< +/td></tr><tr><td>Country:USA</td><tr><td>State/Province/Territory:&nb +sp;Colorado</td></tr><tr><td>City:&nbsp;Loveland</td></tr><tr><td>Sit +e rating:&nbsp;10</td></tr><tr><td>Comments:<br>Testing my entry</tr> +<tr><td></table> <!--END:-->
    Yes, I am completely aware that I should generate my HTML on the fly but I haven't had time to re-write the script in order to do that. My main problems are figuring out what I need to do to manipulate the strings (I'm sure I'm just thinking too hard) in order to break them into their separate messages. If you could possible give me what you would normally do in a case like this, that would definitely help.
      Actually, there's a preference you can set in your profile that will at least make replies show up. Anyhow, yeah, this doesn't look like the easiest format to parse, because your data is all mixed into the HTML. The easiest way to deal with this, IMO, is to parse the whole thing into memory, and write it all back out if there are changes. Unfortunately, this is also slow, but at least the code will be clean. Here's code to do it:
        I agree. This flat file crap isn't cutting it. MySQL is so undbelieveably better. Thanks, I'll take a look at that and I'll get this into a db soon.