Unless you're working with quite a large number of records, your current system is just fine. A few modifications wouldn't hurt, though:
open (DATABASE,">$database"); @DB=<DATABASE>;
If you open a file for write, it's automatically emptied. What exactly is the point of the second line above, especially considering you never use @DB anywhere else in your script?
if ($agent_name eq $input{'nagent_name'} && $agent_phone eq $input{'na +gent_phone'} ){
nagent? This can't be intentional, considering this is the only line that uses nagent.
fopen (ORGDB,"<$database"); @ODB=<ORGDB>; close (ORGDB); ... foreach $rec (@ODB){ chomp($rec); ($agent_name,$agent_phone,$agent_cell,$agent_email)=split(/\|/ +,$rec);
You don't have to chomp each line if you're only doing matches on the first two fields. You also don't need the variable $rec:
for (@ODB) { ($agent_name,$agent_phone,$agent_cell,$agent_email)=split(/\|/);
In addition, you can increase the efficiency of your file access by using read / split instead of assigning the contents of the file handle to an array. You may also be able to increase efficiency by modifying the found line inside the array and then writing the whole array at once (using join), but I haven't tested that yet and don't know if there's a time gain.

Bottom line, you don't need a database unless you have at least several thousand records. Just modify your script for higher efficiency. Beyond that, I'd use mySQL. :)


In reply to Re: Convert script to use MySQL by TedPride
in thread Convert script to use MySQL by lisaw

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.