> > > 1) unless you have previously populated the db file, it will start off
> > > as
> > > empty.
> > >
> > > I guess, this is my most basic and pressing question.  A file by the name
> > > mockalias exists which already has the usernames and e-mail addresses
> > > separated by :
> > > When I use the tie command, am I not pulling up all the existing information
> > > in that file, into a hash?
> > >
> >
> >   ... so you mean this mockalias is actually a text file contain records one
> > entry per line with the symbol ":" as the delimitor?
>
> Yes, it is. DB_file is not the best option, is it, in such a case?
>

  I'm sorry I've over looked your question, my apology.

  no, actually Berkely DB is an excellent choice, it gives you all the features
(delete, search, add, update) you wanted while consuming very little resources.

  But since your data is in a text file, you will have to first convert them into a
Berkely DB first before you can use it.  The following code should the job.

my ($key, $values);
open Fin, "mockalias";
while (<Fin>)
{
  ($key, $value) = split(/:/, $_)
  $ALIAS{$key} = $value;
}
close Fin;


put this loop between the tie and untie statement and it will load the vlaues from
the mockalias file and convert it into a hash and at the same time storing the
change into the BerkelyDB file.

Remember to pick a different name for your berkely db file, .. mockalias.db should
be a good choice. (^_^)

Tor.

Reply via email to