Gossamer Forum
Home : General : Perl Programming :

DB_File to store Records Question

Quote Reply
DB_File to store Records Question
hello,

i need to set up a simple db and want to use DB_File. the db consists of a username as a key, and then things like address => 'whatever' , boss => 'tom', email => 'me@perl.org' etc....

question: can i use DB_File to store hash of hashes or do i have to use MLDBM (which i prefer not to)

if so, can someone provide an example here? here's what i had, but doesn't seem to work

tie (%h, "DB_File", "/home/db/share/perl/records.db", O_RDWR|O_CREAT, 0644, $DB_HASH) or die "Sorry";

### add a record via hash of hash

$h{adrock}{boss} = "evilman";

in another block i access the file again and do something like

for my $key (keys %h) {
print "$key\t";
### prints "adrock"

### now, i want to print "evilman" how do i do it ? or should i add the records differently ?


}

can someone help?? Thanks!!!!!!!

-adrock