Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > why doesn't my dbm file save my data?

Reply
Thread Tools

why doesn't my dbm file save my data?

 
 
jaialai technology
Guest
Posts: n/a
 
      12-04-2010
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);
 
Reply With Quote
 
 
 
 
jaialai technology
Guest
Posts: n/a
 
      12-04-2010
Nevermind. I see my error.
Silly mistake.
$TEST_DATA[$ARGV[0]]=$ARGV[1];
should read
$TEST_DATA{$ARGV[0]}=$ARGV[1];

 
Reply With Quote
 
 
 
 
Marc Girod
Guest
Posts: n/a
 
      12-04-2010
On Dec 4, 8:22*pm, jaialai technology <jaialai.technol...@gmail.com>
wrote:

> Why?


Because you do not write into your hash, but into a @TEST_DATA array:

> $TEST_DATA[$ARGV[0]]=$ARGV[1];


use strict; would have told you.

$TEST_DATA{$ARGV[0]}=$ARGV[1];

Marc
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Why is it that *dbm modules don't provide an iterator? (Languagedesign question) Akira Kitada Python 3 04-11-2009 02:13 PM
Why is it that *dbm modules don't provide an iterator? (Languagedesign question) Akira Kitada Python 0 04-09-2009 03:22 PM
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
dbm file locking with different versions of perl Matt Johnson Perl 0 08-08-2003 11:58 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57