sulfericacid
Programmer
For some reason I can't get my database to store information anymore. Mind I was originally using SDBM which worked for the most part, ever since I switched over I can't get it to save anything.
I asked this question to someone and their answer was "After you tie %chat to DB_File you re-tie it to Tie::IxHash. (So, you never really use DB_File at all.)". If this is the reason, can someone explain how to fix this?
use strict;
use warnings;
use POSIX;
use CGI qwstandard start_table end_table);
use lib "";
use Tie::IxHash;
my $columns = 50;
use Text::Wrap qw( wrap $columns );
use DB_File;
my %chat;
my %chatorder;
my @words = ();
my $chat = "chat.dbm"; # location of database
my $file = "count.txt"; # location of count file
unlink "chat";
tie %chat, "DB_File", "chat", O_CREAT | O_RDWR, 0644, $DB_HASH
or die "Cannot open file 'fruit': $!\n";
tie %chat, "Tie::IxHash"
or die "Cannot tie %chat to Tie::IxHash : $!\n";
tie %chatorder, "Tie::IxHash"
or die "Cannot tie %chatorder to Tie::IxHash : $!\n";
print header, start_html;
my $num;
foreach ( keys(%chat) ) {
$num++;
}
print "DB keys: $num";
my $name = param('name');
my $message = param('message');
my $cnt;
if (param) {
if ($name) {
if ($message) {
my $keeptime = join ( '~', $hour, $min, $sec );
my $info = join ( '~~', $name, $message, $keeptime );
$chat{$cnt} = $info;
}
else {
print "Message was missing, data not sent.<br>";
}
}
else {
print "Name was missing, data not sent.<br>";
}
}
foreach ( reverse keys(%chat) ) {
$add++;
if ( $add <= 10 ) {
$chatorder{$_} = $chat{$_};
}
}
foreach ( reverse keys(%chatorder) ) {
my ( $name, $message, $time ) = split /~~/, $chatorder{$_};
$message = wrap( '', '', $message );
print Tr(
td(
{ -width => '700' },
"<font color=blue><$name @ $time></font>$message"
)
),
"Age is nothing more than an inaccurate number bestowed upon each of us at birth as just another means for others to judge and classify us- sulfericacid
I asked this question to someone and their answer was "After you tie %chat to DB_File you re-tie it to Tie::IxHash. (So, you never really use DB_File at all.)". If this is the reason, can someone explain how to fix this?
use strict;
use warnings;
use POSIX;
use CGI qwstandard start_table end_table);
use lib "";
use Tie::IxHash;
my $columns = 50;
use Text::Wrap qw( wrap $columns );
use DB_File;
my %chat;
my %chatorder;
my @words = ();
my $chat = "chat.dbm"; # location of database
my $file = "count.txt"; # location of count file
unlink "chat";
tie %chat, "DB_File", "chat", O_CREAT | O_RDWR, 0644, $DB_HASH
or die "Cannot open file 'fruit': $!\n";
tie %chat, "Tie::IxHash"
or die "Cannot tie %chat to Tie::IxHash : $!\n";
tie %chatorder, "Tie::IxHash"
or die "Cannot tie %chatorder to Tie::IxHash : $!\n";
print header, start_html;
my $num;
foreach ( keys(%chat) ) {
$num++;
}
print "DB keys: $num";
my $name = param('name');
my $message = param('message');
my $cnt;
if (param) {
if ($name) {
if ($message) {
my $keeptime = join ( '~', $hour, $min, $sec );
my $info = join ( '~~', $name, $message, $keeptime );
$chat{$cnt} = $info;
}
else {
print "Message was missing, data not sent.<br>";
}
}
else {
print "Name was missing, data not sent.<br>";
}
}
foreach ( reverse keys(%chat) ) {
$add++;
if ( $add <= 10 ) {
$chatorder{$_} = $chat{$_};
}
}
foreach ( reverse keys(%chatorder) ) {
my ( $name, $message, $time ) = split /~~/, $chatorder{$_};
$message = wrap( '', '', $message );
print Tr(
td(
{ -width => '700' },
"<font color=blue><$name @ $time></font>$message"
)
),
"Age is nothing more than an inaccurate number bestowed upon each of us at birth as just another means for others to judge and classify us- sulfericacid