On Mon, 26 Aug 2002, Rowan Reid wrote:
>
>
> I'm learning as best I can using every book orielly makes. I am trying
> to saved a complex data structure (hash). I'm trying to use Berkly
> DBFile and tie. I am unable to store the file ie retrieve info once I
> have exited the program. Once I tie a hash toe the file access the
> contents should be the same as accessing the contents of the hash
What have you done so far? If you had posted your code or a snippet of it
we can help you better. Here is a small example. You might also want to
take a look at flock (perldoc -f flock).
#!/usr/local/bin/perl -w
use strict;
use DB_File;
my ($tiedb, %tied_hash);
$tiedb = tie (%tied_hash, 'DB_File', 'tie_example.db', O_CREAT|O_RDWR, 0666) or
die "dbcreat tie_example.db failed : $!\n";
# Once you exit from the program you will have to tie again to access the
# values. My guess is you are not doing this.
foreach (keys (%tied_hash)) {
print "$_ ---> $tied_hash{$_}\n";
}
while (<STDIN>) {
chomp;
$tied_hash{$_} = $_;
}
$tiedb->sync;
undef ($tiedb);
untie ($tiedb);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]