in reply to Can Perl create its own searchable db?

If your host is a UNIX-based server, then you can use the Berkely-style database that's inherent to the system. DBD::File is where you want to go, as referenced above.

Since you're just storing records in a flat table (I'm assuming you don't want a lot of tables - Database guys love them, but unless you're comfortable with DB normalization, I'd stick with a flat table. - http://www.devshed.com has a good lesson on database structure, but their website is broken ATM and I can't get you a direct link.

The other possibility is to just write all your fields to a delimited text file. Just append to the file every time the form is submitted, and then you can open your datafile up in a spreadsheet and sort to your heart's content.

Here's a tweakable example. I fully admit that this code can be optimized and it *will* have to be edited for your form. I'm doing this on purpose wo you learn how it works better. =)

use CGI; $outputString = param('formfield1') . "|" . param('formfield2'); open OUTPUTFILE, "filename.txt"; print OUTPUTFILE $outputString . "\n";
I'd also spit them out a second page saying thanks for filling out your 100-field form. One possible easy way is HTML::Template. Hope this helps.

UPDATE: Corrected bad CPAN Link

Replies are listed 'Best First'.
Re: Yes... sort of.
by Elliott (Pilgrim) on Jan 11, 2003 at 01:02 UTC
    <quote>Since you're just storing records in a flat table (I'm assuming you don't want a lot of tables - Database guys love them, but unless you're comfortable with DB normalization, I'd stick with a flat table.</quote>

    Well.. hmm... Perl is so great at text searching that this advice is less barmy than it might be elsewhere - but I still say learn normalisation and enjoy a happier life! It's not hard and one day, when you want to search on a combination you never thought of before, you'll be glad you did.

    Later... nuts! My markup's wrong but it makes the point!

Re: Yes... sort of.
by Bismark (Scribe) on Jan 10, 2003 at 18:59 UTC
    So if I am understanding your answer, this method would create a text file that would be appended everytime the form is submitted. Then if say the first time it is submitted I have report #100, then it is submitted again so now I have report #101. These would be in a delimited text file. Now I want to search the reports so that I can see report number 101. So I would want to load just that one section of the text doc. Or can I create a seperate text doc each time the form is submitted and then just load that one file back into the program. It seems to me that I could maybe set the text filename as a variable and then fill it with the report number which the program generates each time a new report is filed. The purpose of this form is to replace a paper version that we now use when ever we perform a first article inspection on a new product. That is the reason for the large size of the form.
      Yes, you can get a timestamp in UNIX time format by calling time(). It'll give you an integer value of seconds since Jan 1, 1970, so you can be fairly sure that you'll get a unique value. So when you call your open( FILEHANDLE, "filename.txt"); you can first say:
      $filename = "prefix-" . time() . ".txt"; open( FILEHANDLE, $filename );
      The only problem you're going to have is when you need to compare reports. It's going to be a beast to write a comparison program to read all these files and give you relevant data. If you never need to do that, then separate files would probably be the ideal solution for you. If you *do* need comparison ability, then a real database is probably the best idea. If so, I'd either install a database server (MySQL is free and can be installed on most any platform. Postgres SQL is considered by many to be superior, and even more free. I *know* it runs on Linux and the BSDs, but I'm not sure what other platforms it's been ported to... good oods on any *NIX)