why doesn't my dbm file save my data?

  • Thread starter jaialai technology
  • Start date
J

jaialai technology

The code below is saved to a file called, say, temp.pl.
I run $perl temp.pl a b
and then I immediately run
$perl temp.pl c d
On this second run I expect to see the key 'a' of my first run but I
do not.
Why?
I am not getting any errors and the
associated db files are in /tmp
-rw-r--r-- 2 jt jt 12306 2010-12-04 14:53 test_db.dir
-rw-r--r-- 2 jt jt 12306 2010-12-04 14:53 test_db.pag


----
temp.pl
----
my %TEST_DATA;
dbmopen(%TEST_DATA,"/tmp/test_db",0666);
foreach my $key (keys %TEST_DATA){
print "$key\n";
}
$TEST_DATA[$ARGV[0]]=$ARGV[1];
dbmclose(%TEST_DATA);
 
J

jaialai technology

Nevermind. I see my error.
Silly mistake.
$TEST_DATA[$ARGV[0]]=$ARGV[1];
should read
$TEST_DATA{$ARGV[0]}=$ARGV[1];
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top