in reply to perl db_file

Here is the "boiled down" source of the entire post.cgi script which is supposed to add the new key. However, sometimes it fails and sometimes it succeeds, seemingly randomly.

Replies are listed 'Best First'.
Re^2: perl db_file
by jZed (Prior) on Nov 12, 2005 at 05:23 UTC
    I don't know why the script is dying where you show. Use warnings and strict, and errorcheck/die for tie and file opens. Those may help you find the problem. Once you've found the problem, I also strongly advise replacing the CONTENT_LENGTH stuff with CGI.pm. Good luck!
Re^2: perl db_file
by keiusui (Monk) on Nov 12, 2005 at 05:24 UTC
    #!/usr/bin/perl print "Content-type:text/html\n\n"; use CGI::Carp qw(fatalsToBrowser); use DB_File; my $x = tie(%data, DB_File, "data.db"); die unless $x; $data{"1131764522.1131769129"} = "1131764522.1131769129\tJiskha Webmas +ter\t\tMt Tarawera\t\t70.228.93.58" || die "$!"; untie(%data); print "success!"; 1;
      This script works for me:
      #!/usr/local/bin/perl use warnings; use strict; use DB_File; my %data; tie(%data, 'DB_File', "data.db") or die $!; $data{"1131764522.1131769129"} = "1131764522.1131769129\tJiskha Webmas +ter\t\tMt Tarawera\t\t70.228.93.58" || die "$!"; untie(%data) or die $!; %data=(); print "success!\n"; tie(%data, 'DB_File', "data.db") or die $!; print $data{"1131764522.1131769129"};