in reply to addy book entries..

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...

Replies are listed 'Best First'.
RE: Re: addy book entries..
by Aighearach (Initiate) on Jul 16, 2000 at 03:51 UTC
    OTOH, the program specification could include, or change to include, use of ASCII data files. The nice thing about not using a database when you data is just ASCII, is that you can read it, edit it, port it, etc., without needing to change your program. That is, the users of the program have access to their data. As this is something to be stored in ~, it seems better to use ASCII. Browsing my own ~/.* files, this seems to be pretty standardized.
    Paris Sinclair    |    4a75737420416e6f74686572
    pariss@efn.org    |    205065726c204861636b6572
    I wear my Geek Code on my finger.
    
      very very very true... i am a BIG fan of ascii files for configuration information... however, data files, i like making it difficult for people to edit them by hand... i have discovered that if you make datafiles easy to edit by hand, the "users" will most likely hurt the file format and cause your program to die... (i remember once someone edited a datafile by hand, and it caused a race condition that brought down a Sun E450... that was painful...) so, i guess, once again, the point becomes: "what are they asking you to do, what will they ask you to do? use the right tool for the right job."