Simple Database

This function is a simple file-driven database. Entries in the database are identified by a name. The program reads a file that contains lines of the form:

put name value # assign entry "name" the value "value"
get name       # prints the value of entry "name"
delete name    # removes the entry "name"
length name    # prints the length of entry "name"
dump           # displays the entire database

To make processing easier, the names are defined to be “Perl words” (which means that they contain letters, numbers, and/or underscores—the characters that the '\w' regular expression escape matches). The spaces in between operators and names can be any number ...

Get Find the Bug A Book of Incorrect Programs now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.