I got this simple script that i can't get it work. I am trying to tie an existing db but it dies when tie.
the db file exists in the same dir where the perl script is. and it's read/writable by me.

#!/usr/bin/perl -w use strict; use DB_File; my %db; tie (%db,'DB_File',"mydb.db",O_RDONLY) or die "tie : $!"; untie %db;
it simply dies with tie :  at t.pl line 9.

I followed tye's suggestion and traced it with perl debugger. but I don't see anything wrong (still new to perl debugger) here is the trace if it helps

main::(t.pl:9): tie (%db,'DB_File',"movies.db",O_RDONLY) or die "tie : + $!"; DB<1> s Fcntl::AUTOLOAD(/usr/lib/perl5/5.6.0/i386-linux/Fcntl.pm:203): 203: (my $constname = $AUTOLOAD) =~ s/.*:://; DB<1> s Fcntl::AUTOLOAD(/usr/lib/perl5/5.6.0/i386-linux/Fcntl.pm:204): 204: my $val = constant($constname, 0); DB<1> s Fcntl::AUTOLOAD(/usr/lib/perl5/5.6.0/i386-linux/Fcntl.pm:205): 205: if ($! != 0) { DB<1> s Fcntl::AUTOLOAD(/usr/lib/perl5/5.6.0/i386-linux/Fcntl.pm:216): 216: *$AUTOLOAD = sub { $val }; DB<1> s Fcntl::AUTOLOAD(/usr/lib/perl5/5.6.0/i386-linux/Fcntl.pm:217): 217: goto &$AUTOLOAD; DB<1> s Fcntl::__ANON__[/usr/lib/perl5/5.6.0/i386-linux/Fcntl.pm:216](/usr/lib +/perl5/5.6.0/i386-linux/Fcntl.pm:216): 216: *$AUTOLOAD = sub { $val }; DB<1> s DB_File::TIEHASH(/usr/lib/perl5/5.6.0/i386-linux/DB_File.pm:264): 264: tie_hash_or_array(@_) ; DB<1> s DB_File::tie_hash_or_array(/usr/lib/perl5/5.6.0/i386-linux/DB_File.pm: +244): 244: my (@arg) = @_ ; DB<1> s DB_File::tie_hash_or_array(/usr/lib/perl5/5.6.0/i386-linux/DB_File.pm: +246): 246: my $tieHASH = ( (caller(1))[3] =~ /TIEHASH/ ) ; DB<1> s DB_File::tie_hash_or_array(/usr/lib/perl5/5.6.0/i386-linux/DB_File.pm: +249): 249: if @arg >= 5 && ref $arg[4] && $arg[4] =~ /=HASH/ && t +ied %{ $arg[4] } ; DB<1> s DB_File::tie_hash_or_array(/usr/lib/perl5/5.6.0/i386-linux/DB_File.pm: +252): 252: if ($db_version > 1 and defined $arg[4] and $arg[4] =~ /RE +CNO/ and 253: $arg[1] and ! -e $arg[1]) { DB<1> s DB_File::tie_hash_or_array(/usr/lib/perl5/5.6.0/i386-linux/DB_File.pm: +259): 259: DoTie_($tieHASH, @arg) ; DB<1> s tie : at t.pl line 9, <IN> line 14. Debugged program terminated. Use q to quit or R to restart,
line 244:        my (@arg) = @_ ; here @_ contains DB_File,mydb.db,0


In reply to DB_File tie failed by Qiang

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.