I was interested to see if I could get this to work. I couldn't. :-) My thought was to have something like this:
Define each smiley like
$smilie{filename} = emoticon; so you would have something like
$smilie{smile} = ":)"; $smilie{frown} = ":("; $smilie{wink} = ";)"; And then using the following code:
Code:
foreach $col (keys %rec) {
foreach $file (keys %smilie) {
$graphic = "<img
url/to/smilies/dir/$file.gif>";
$rec{$col} =~ s/$smilie{$file}/$graphic/g;
}
}
But it doesn't work. The reason it doesn't work is because of the nature of smilies -- the fact that they use ) and (. The substitution causes the regular expression to be interpreted as though they are really parentheses and not just characters. I tried adding \ before them and it still didn't work.
What did work is to use words to define the smilies. Here's a little script that worked just as I wanted it to:
Code:
$rec{'Name'} = "Fred smile";
$rec{'Address'} = "Bedrock frown";
$smilies{smile} = "smile";
$smilies{frown} = "frown";
$smilies{wink} = "wink";
foreach $col (sort keys %rec) {
foreach $file (sort keys %smilies) {
$graphic = "<img url/to/smilies/dir/$file.gif>";
$rec{$col} =~ s/$smilies{$file}/$graphic/;
}
}
That gets you what you want, but there's two problems. One is that people are used to using smilies and not typing out the name of the smilie. The other is that you wouldn't be able to use the word anywhere else.
But maybe this will help to point you or someone else in the right direction. :-)
JPD
----------------------------------------------------
JPDeni's DBMan-ual How to
ask questions the smart way.