|Welcome to the Monastery|
Re: flat file databasesby Zero_Flop (Pilgrim)
|on Aug 12, 2004 at 05:38 UTC||Need Help??|
How big are these files?
Does the first file only contain one record, or multiple records?
If it has only one record I would try doing this as follows:
Open and read the first file.
Loop though the second file reading one line at a time.
Read the line, compare to the record you want to change to the record you just read, then write to a temp file the correct entry.
Once you have gone though the entire second file. You will have two files, the original second file and a temp file that is identical to the second file but with the record change. If your record change was successful then rename the old second file to something like data.old and rename the temp file to the name of the second file. ( this give you a roll back ability if something goes wrong) You can have multiple data.old files to act as an undo feature.
If you have multiple lines you have to replace, I would consider using a module on CPAN that would give you a generic interface to your data.
P.S. You may just be off a little in your code. Posting the reivant part will help in supporting you!