You are using the same keys to the same database each time so, of course, it blows away the previous values.
You could incorporate the order number into each key:
sub dborder { dbmopen(%order, "order", 0644) || die "Unable to open db : $!"; $order{'o'} = $order; $order{"name$order"} = $name; $order{"address$order"} = $add; $order{"city$order"} = $city; $order{"state$order"} = $state; $order{"zip$order"} = $zip; $order{"country$order"} = $country; $order{"email$order"} = $email; $order{"cost$order"} = $cost; $order{'a'.$order} = [@food]; $order{'b'.$order} = [@fries]; $order{'c'.$order} = [@onionrings]; $order{'d'.$order} = [@drink]; $order{'o'}++; dbmclose(%order) || die "Cannot close dbm file.\n"; }
Or you could just store all of this under a single key that is the order number if you use something like MLDBM (?) to serialize your Perl data structures. Since you aren't already using MLDBM, I don't think your [@food] will actually store anything useful in the database. But then I don't know much about this kind of thing (and wasn't going to reply) so I hope this is of some help.
- tye (but my friends call me "Tye")In reply to (tye)Re: Adding records to a hash db
by tye
in thread Adding records to a hash db
by curtisb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |