sulfericacid has asked for the wisdom of the Perl Monks concerning the following question:

The database I'm using kind of skips around every once in a while. At first I thought it was because the limit of 1008 bytes per key (though I have no idea how many a-zA-Z characters are in equivelance to a byte) until I did some further testing.

  • test 1: Post 30 messages with a plain 50 character message. PASS
  • test 2: Post 30 messages with two face subs (smiley face/sad face). FAIL: DB broke apart at message 15
  • test 3: Post 30 messages with a non-separated word consisting with 400 characters. FAILED: DB broke up at message 10
  • test 4: Post 35 messages containing plain text for messages 1-14, image conversion using (smiley/sad face) for 15, 16-30 text, 31 for image conversion.. DB continued after one usage of a subs for an emoticon past message 20, after attempt of using a second s// DB crashed at message 30.

    It looks like as long as the messages aren't too long and they don't contain any special functions (making emoticons) the database and the script will run properly but if really lengthy one-word messages are sent or images are used the database likes to die at or around message 15-17.

    My ideas: None but I find it hopeful since it usually crashes around the same time. Do you have any suggestions (besides MySQL)? (by breaking apart I mean the contents from the DB are not printed out in insertion order. Insertion order is retained unless there are substitutions it looks like).

    if (param) { if ($name) { if ($message) { open( LOG, "$file" ); # open count log for ID $cnt = <LOG>; close(LOG); $cnt++; open( LOG, "> $file" ); print LOG $cnt; close(LOG); $name =~ s/</&lt\;/g; # removing exploit $message =~ s/</&lt\;/g; # removing exploit $name =~ s/$_/****/g for @words; # say goodbye to swear words $message =~ s/$_/****/g for @words; # say goodbye to swear words $message =~ s/:\)/\<img src=\"$imagedir\/smiley.gif\"\>/g; # happy emo +ticon $message =~ s/:\(/\<img src=\"$imagedir\/sad.gif\"\>/g; # sad emoti +con $message =~ s/:p/\<img src=\"$imagedir\/tongue.gif\"\>/g; # tongue em +oticon $message =~ s/:P/\<img src=\"$imagedir\/tongue.gif\"\>/g; # tongue1 e +moticon $message =~ s/:o/\<img src=\"$imagedir\/oh.gif\"\>/g; # oh emotic +on $message =~ s/:O/\<img src=\"$imagedir\/oh.gif\"\>/g; # oh1 emoti +con $message =~ s/\*hug\*/\<img src=\"$imagedir\/hug.gif\"\>/g; # hug emo +ticon $message =~ s/\*flower\*/\<img src=\"$imagedir\/flower.gif\"\>/g; # f +lower emoticon $message =~ s/\*wink\*/\<img src=\"$imagedir\/wink.gif\"\>/g; # wink +emoticon $message =~ s/\*devil\*/\<img src=\"$imagedir\/devil.gif\"\>/g;# devil + emoticon $message =~ s/\*love\*/\<img src=\"$imagedir\/love.gif\"\>/g; # love +emoticon $message =~ s/\*sleep\*/\<img src=\"$imagedir\/sleep.gif\"\>/g;# sleep + emoticon $message =~ s/\*conf\*/\<img src=\"$imagedir\/confused.gif\"\>/g;# sle +ep emoticon 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 (%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

    20030627 Edit by Corion: Fixed runaway italics

  • Replies are listed 'Best First'.
    Re: SDBM acting weird
    by PodMaster (Abbot) on Jun 27, 2003 at 06:10 UTC
      At first I thought it was because the limit of 1008 bytes per key (though I have no idea how many a-zA-Z characters are in equivelance to a byte) until I did some further testing.
      Thats not exactly right. Like the documentation says:
      The most important is that the length of a key, plus the length of its associated value, may not exceed 1008 bytes.
      Also, unless you're dealing with utf (`perldoc perlio', `perldoc open'), you're dealing with single byte characters.

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.