in reply to Re: storing a large hash in a database
in thread storing a large hash in a database

With your great advise, I could do it with DB_File. Now I have a DB_file (*.db) in my hard disk which is about 5 GB, However, I can not re-access it.
$DB_BTREE->{'flags'} = R_DUP ; my $x = tie %dictf, "DB_File", "f.db", O_RDWR|O_CREAT, 0666, $DB_BTREE + or die "Cannot open file f.db: $!\n"; my $number = keys %dictf; print "$number\n"; my $number = keys %dictf; print "$number\n"; $key = $value = 0 ; for ($status = $x->seq($key, $value, R_FIRST) ; $status == 0 ; $status = $x->seq($key, $value, R_NEXT) ) { print "$key -> $value\n"; }
and the result is:
0
while I have:
-rw-r--r-- 1 xxxxx xxx 4.2G Dec 3 14:03 f.db
as my database. What do I do wrong?

Replies are listed 'Best First'.
Re^3: storing a large hash in a database
by hbm (Hermit) on Dec 05, 2011 at 16:18 UTC

    Try tie'ing without O_CREAT:

    tie %dictf, "DB_File", "f.db", O_RDWR, 0666, $DB_BTREE or die "Cannot +open file f.db: $!\n";

    So, in hindsight, my unlink was unnecessary. And note that the default option is O_CREAT|O_RDWR, so you need to be explicit if you don't want to wipe it out.