My suggestion is to parse this all once (perhaps with something like HTML::TokeParser) and place your records in a database. If you don't want to (or, for some reason, can't) run a full-on RDMBS, check out DBD::SQLite2 for a file-based RDBMS-in-a-Perl-module solution. For what you're doing, it should perform well enough.
Once you have these in a database, you can revise your guestbook code to (a)insert records instead of editing files, (b)generate HTML dynamically using something like HTML::Template, and (c)add your search function.
Your user table might look something like this:
ID UserName === ============ 1 Doug 2 JH
And your comments table would have a PostingUserID column that references the ID above. Your search, then, would look up the ID number of the user you want and then scan your comments table for posts by that ID. This is pretty standard DB stuff, so I apologize if I'm oversimplifying -- I don't know how familiar with DBs you are.
End result, you do a bit more work up-front, but you have code that's much more scalable both in terms of adding new features and handling more users. For example, migrating to a more robust DB like MySQL in the future (in order to deal with tens of thousands of users, perhaps) becomes relatively simple.
In reply to Re: Search function for guestbook history?
by radiantmatrix
in thread Search function for guestbook history?
by JCHallgren
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |