Badd has asked for the wisdom of the Perl Monks concerning the following question:

Excuse me never posted before, brief as possible. 2 cgi-scripts, flatfile database. 1 to add, edit, delete. Another to search. Using Html templates. Search script will lookup 1 dbname at a time. I want to search multiple files at the same time. How do you change the search script to lookup multible dbnames instead of 1 dbname at a time. Full Search Script can be found at http://www.verrex.ca/Help_With_Search_Script.txt Please Help Me

Janitored by Arunbear : The OP's script is very long so I've posted in a reply below. Also changed title from 'How do you search multible dbnames?'

  • Comment on How do you search multiple flat file databases?

Replies are listed 'Best First'.
Re: How do you search multiple flat file databases?
by jfroebe (Parson) on Oct 26, 2004 at 13:36 UTC

    Hi Badd,

    I think what you are referring to is a join between two flatfiles. DBD::CSV doesn't provide the mechanism to do this, so you would have to write one yourself. Essentially, get the result set from flatfile#1, store it in a hash, get the result set from flatfile#2, store it in a hash. Compare the two hashes to produce the data set you want.

    This is where you have to weigh whether to stick with flatfiles or go with a more feature rich dbms. Which to choose depends on many criteria but if the flatfiles will wor for you, then you might as well stick with it else you will have to learn SQL - not altogether bad, but it is something more. ;-)

    Jason L. Froebe

    Team Sybase member

    No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

      Thank You Very much for your speedy response. I appreciate your input. You and this website are great. Thanks again.
Re: How do you search multiple flat file databases?
by Jasper (Chaplain) on Oct 26, 2004 at 13:38 UTC
    Unless I'm interpreting the script incorrectly, and I did recoil in horror fairly quickly, your friend seems to have rolled his own database. Whilst I'm sure he enjoyed the challenge, surely using DBX (or similar), i.e. an already tried and tested interface to a flat file database, is better in every way. I'd rewrite that if I were you, to something much more simple.
      Thanks Jasper. You and Jason are a bonus to your community for the speedy responses. Thanks. Any quick solutions?
Re: How do you search multiple flat file databases?
by Arunbear (Prior) on Oct 27, 2004 at 10:54 UTC

    I'm posting the OP's question and script (copied from the above mentioned URL) here for the benefit of anyone reading this thread:


    If you are reading this, Thank You for your assistance. These scripts were written for me by a friend before he left to work overseas. I have little experience with Perl. Any assistance would be a great help thanks. Please note that each search request can only search one database file at a time. I want to customize to search multiple files at the same time. I currently use the following form to search single dbname files from html template.
    <a href="/cgi-bin/search.cgi?template=summary.htm&dbname=dbname&displ +aynew=yes&action=searchdbdisplay"> Display all new records</a>
    After attempted customization, i want use the following form (example only) to search multiple files (of the same field definitions/format):
    <a href="/cgi-bin/search.cgi?template=summary.htm&dbname=dbname1,dbnam +e2,dbname3& displaynew=yes&action=searchdbdisplay">Display all new records</a>
    or
    <a href="/cgi-bin/search.cgi?template=summary.htm&dbname=**dbname**& displaynew=yes&action=searchdbdisplay">Display all new records</a>
    In the "Summary Report" template i want to use this link for sending the user to the detail report of the record displayed
    <a href="/cgi-bin/search.cgi?template=summary.htm&dbname=**dbname**&ke +y2=**key**& action=searchdbdisplay">Detail Report</a>
    Can the Perls of Wisdom, assist me in my struggle. I have been trying for 2 months to find a solution.
    Thanks Again

    Complete Search Script:


      Wow, i thank you for the assistance in making my question legable for wise men. Your the best, Thanks