473,513 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ


Modifying Records Part 4

By Blair Ireland
Senior Editor, TheScripts.com

    if ($found) {

Since $found started off as a null value, and if the record was found it became non-null, we will only write to the file if we found and changed the record.

        open (DATABASE, ">".$file);

The database file is opened again with the handle DATABASE in write-only mode.

        if ($flock) {
            flock(DATABASE, 2);
        }

Once again, only if we specified we want flock to work, flock will be invoked on the DATABASE handle and lock the file.

        print DATABASE $output;
        close (DATABASE);

DATABASE has the contents of $ouput printed to it, and DATABASE is closed, automatically removing the file lock.

    }         &header("Record Edited Successful");

Our header procedure is called again, with our current title.

        print qq~<CENTER>Here Is Your Record<p>~;

        my (%result) = get_record($form{'key'});
        if (%result) { &build_record_page(%result); }       
          else {    print "Error - No Record Added";    }

This bit is just like add_record_two. We try to see if we can find the record just edited in the database, and if we find it, the &build_record_page sub is invoked, showcasing the record's values. Otherwise, an error is just printed out.

        print qq~</CENTER>~;
        &footer;

Here the footer is printed once again.

}

And we finish off sub edit_four.Geez, do you realize what you just made? Not only is it a database, but this database sorts records, and even searches by selected fields if you want. Thats pretty good.... I just hope you weren't lost anywhere or I'm going to be getting alot of e-mails soon.

« Modifying Records Part 3  

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.