http://qs321.pair.com?node_id=271216

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

Still working on the same problem, I'm making this question really short with as few codes as possible hoping more people will read it.

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>&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