in reply to Google-like query of ASCII text with Text::Query or other modules

This may start out sounding like I'm completely off-topic, but I'm not, please bear with me.

When writing CGI applications, the overwhelming consensus is to put your web pages into templates of some sort (whether that be with Text::Template, HTML::Template, or any of a number of others) to separate out the data from the logic. (Then there's Text::ScriptTemplate, but let's not go there ;-})

In your application, you say you have the text in scalars. Why not separate them out into a real data store of some sort? That could be files or a database. Both of these have fairly universal access methods - you can access them, as well as the index/query engine. (In fact, the database could be that very index/query engine.) I realise that this would likely be a fair bit of up-front work, but it's likely to pay off in the long run. The text could be updated by anyone, not just people who know how to get around perl. You could create another CGI app to update it - it's much easier to programmatically create new files or rows in a table than it is to programmatically update perl code!

Once you've changed your code to work "inside the box", then you're following an expected (and easy-to-deal-with) paradigm, and lots of other benefits will accrue. Sometimes, conformity is a good thing ;-)

  • Comment on Re: Google-like query of ASCII text with Text::Query or other modules