If for some reason, you can not use a database (which although the program specification may not call for shared addressbooks and stuff like that, trust me, it will change, and you will need a database... program specifications do that...) then my suggestion is as follows:

My suggestion, is that you use the CPAN module MLDBM. What this module alows you to do is store complex data structures within a DBM without you having to deal with all of the complexities of serialization and unserialization. Where I in your situation I would do something like, each entry into the addressbook is a hash:

my $entry = { NAME => "eduardo arino", PHONE => "(555) 555-1212", ADDRESS => "666 Dante Circle, Murfreesboro, TN", EMAIL => "ed@NO_SMAP.home.com" };
and then, index the hash that is the tied MLDBM DB file by whatever it is you wanted, name, phone, address, whatever. Being that you could access it like a hash, your data manipulation problems would be greatly minimized, and being that this is not a speed critical piece of code, the overhead in the MLDBM package would probably not kill you...

then again, there might be some other way of doign it... it's just that whenever i hear people talk of using flat files, I get this feeling that it's going to end up coming back to haunt them... I know the few times i have, it did...


In reply to Re: addy book entries.. by eduardo
in thread addy book entries.. by Crawlings

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.