Hi Monks, I was trying to open an already existing DB file. It has some data in it. but when I try to open it and print it, it wouldn't work(wouldn't enter the while loop). One of the monks suggested me to insert a record and try it. it showed that record. what about the already existing data. Is there any way by which I can retrieve that.
dbmopen(%TEST, "/home/lab/access.db", 0666); #$TEST{'test_key'} = pack 'L', int(rand 2**32); while (($key,$val) = each %TEST) { print $key, ' = ', unpack('L',$val), "\n"; print "test2"; }
if the commented line is uncommented. The output is
test_key = 2412538716 test2
if the line 2 line is not present, it shows nothing. its not entering the while loop. as if the db file is empty. but it is not. file permissions, path etc are ok. the file access.db was created by an other person, one year back, on a mandrake7 machine, using db1.x, DB_File1.808 and perl5. right now, I use db4.x, DB_File1.808 and perl5.8.1. Thanks in advance UPDATE : Hi Dave, thanks for your suggestion, I already tried that and the message in the Die is not printed. So i guess it opens the file and it doesn't find any keys, so it wouldnt enter the while loop. I donno if I'm correct. I read the link that you sent me about dbmopen, but the problem is, I already have an existing 1500 line script that uses the above methos instead of "tie". It will be a lot easier for me to get this one working than changin the entire script. Thank you

In reply to dbmopen not opening a db file by talk2kvj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.