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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.