First real attempt at a DB other than SDBM and came across a problem. Nothing is being saved to the database (it prints to screen one time then after you refresh or add something else it's gone).

This is a real short snippet of the code I'm using, anyone have suggestions?

use strict; use warnings; use POSIX; use CGI qw(:standard 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>&lt;$name @ $time&gt;</font>$message" ) ),


"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

In reply to DB_File, not saving by sulfericacid

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.