dbm problem HELP!

T

Tom

I can write to, close aand reopen a dbm file with hashes of hasjed of hashes
and everything is OK.
Data I write is read back just fine.
However, when I run the program again later on and use the same exact code
to reopen the dbm, al the data is gone.

Here is a snippet of what I am doing:

dbmopen (%nd,$ndbfile,0666) || die "Can't dbmopen $ndbfile: $!";

$stk = "ABC";
$datecode = "20030914";
$druntime = "700";
$data = "12345";

$nd{$stk}{$datecode}{$druntime}{Data} = $data;

dbmclose (%nd) || die "Can't dbmclose $ndbfile: $!";

dbmopen (%nd,$ndbfile,0666) || die "Can't dbmopen $ndbfile: $!";
print "Data: $nd{$stk}{$datecode}{$druntime}{Data}\n";
dbmclose (%nd) || die "Can't dbmclose $ndbfile: $!";

-------
Data: 12345
-------

However, if I rerun the script with just the following, I get this:

$stk = "ABC";
$datecode = "20030914";
$druntime = "700";
$data = "12345";

dbmopen (%nd,$ndbfile,0666) || die "Can't dbmopen $ndbfile: $!";
print "Data: $nd{$stk}{$datecode}{$druntime}{Data}\n";
dbmclose (%nd) || die "Can't dbmclose $ndbfile: $!";

Use of unitialized value in concatenation (.) at C: blah, blah, blah
Date:

Apparently, there is a problem accessing the dbm file, though it is there.
Any help would be greatly appreciated, thanks,
Tom
 
T

Tom

when I just try to assign a sub hash to the top, it never gets assigned
regardless of which run, by the way.
 
G

Gunnar Hjalmarsson

Tom said:
I can write to, close aand reopen a dbm file with hashes of hasjed
of hashes and everything is OK.

No you can't. A simple DBM file only stores keys and values, not
complex data structures.
Data I write is read back just fine.

Sure. The problem is that what you read is not what you think you
read.
However, when I run the program again later on and use the same
exact code to reopen the dbm, al the data is gone.

It was never stored in the DBM file.
Here is a snippet of what I am doing:

dbmopen (%nd,$ndbfile,0666) || die "Can't dbmopen $ndbfile: $!";

$stk = "ABC";
$datecode = "20030914";
$druntime = "700";
$data = "12345";

$nd{$stk}{$datecode}{$druntime}{Data} = $data;

At this point, you have the hash %nd in memory containing the key
'ABC' and a _hash reference_ as the value. However, the DBM file does
not save the hash reference; it just saves a _string_ that looks
something like 'HASH(0x1555198)'.

Apparently, there is a problem accessing the dbm file, though it is
there.

No, that's not the problem. (See above.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top