You can send as many plain text messages of around 500 or so characters and the script will purr if you ask it to. But if you add an emoticon ( :), :( ) ... the script will crash anywhere between 10 and 15 messages from the first time you used it. All it takes is one smiley face for the database to lose it's insertion order and stop posting messages correctly. (oddly enough the swear filter doesn't affect anything).
Can someone please take a look at the snippet below to see what's making the database crash on me?
use Tie::IxHash; my $columns = 50; use Text::Wrap qw( wrap $columns ); require SDBM_File; my %chat; my %chatorder; my @words = (); my $chat = "list.dbm"; # location of database my $imagedir = "http://sulfericacid.perlmonk.org/chat/images"; + # location of image directory (emoticons) tie %chat, "Tie::IxHash"; tie %chatorder, "Tie::IxHash"; tie (%chat, 'SDBM_File', $chat, O_CREAT | O_RDWR, 0644) or die "Couldn’t tie SDBM file '$chat' $!; aborting";; foreach (reverse keys (%chatorder)) { my ( $name, $message, $time ) = split /::/, $chatorder{$_}; $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 = wrap('', '', $message); print Tr(td({-width=>'700'},"<font color=blue><$name @ $time> +;</font>$message")), }
In reply to same database problem by sulfericacid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |