in reply to database problems: repost
Is in serious need of refactoring (for the sake of maintainence). I think it was broquaint that recommended you use a hash for this. Maybe this approach wasn't shown to you properly. The idea is to store the emoticons and just the image name (minus a path and extension). Then you can substitute all emoticons with one expression:$message =~ s/:\)/\<img src=\"$imagedir\/smiley.gif\"\>/g; # happy emo +ticon $message =~ s/:\(/\<img src=\"$imagedir\/sad.gif\"\>/g; # sad emoti +con ... etc. ...
This isn't perfect (doesn't catch emticons with noses), but it is a start. Please study this as it will improve your understanding of regexes, hashes, and laziness. Hope this helps :)use CGI qw(img); my $imagedir = '/path/to/images'; my %emot = ( ':)' => 'smiley', ':(' => 'sad', ':p' => 'tongue', ':P' => 'tongue', ':o' => 'oh', ':O' => 'oh', '*hug*' => 'hug', '*flower*' => 'flower', '*wink*' => 'wink', '*devil*' => 'devil', '*love*' => 'love', '*sleep*' => 'sleep', '*conf*' => 'confused', ); my $data = do{local $/;<DATA>}; $data =~ s/ (:.|\*.*?\*) / img { src => "$imagedir\/$emot{$1}.gif", alt => $emot{$1} } /xeg ; print $data; __DATA__ stuff *sleep* :) stuff *hug* :( stuff :P :p stuff *wink* :o stuff :O stuff *flower* *devil* stuff stuff *love* *conf* stuff
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|