"can anyone point me in the right direction for modifying my code to prevent this?"

Probably not, because you don't show us enough code. How is %phonebook populated? My guess is that it gets updated each time a name is added, but that you don't populate it with the names already in the database.

Note that it is often a dumb idea to have the same information in two places because if it gets out of sync you can end up with very hard to find bugs. The main exception is where you cache data for fast access, which may be the case here. However if the updates are infrequent I'd get rid of %phonebook and check the database first to see if the name is there already.

True laziness is hard work

In reply to Re: working with a database by GrandFather
in thread working with a database by jrp370

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.