I have a chatterbox script that let's the admin add custom emoticons to the system and am having problems getting the s/// to work.

The FACE can be ANYTHING pretty much. It can be a word, a series of letters and numbers, some characters like *help* or <help> or pretty much anything. The only thing that's required is the FACE be separated by a space on each side so it doesn't subsitute things like "face" in the word "preface".

id is just a number name is the name the called it (ie: SmileyFace) location is the URL of the image of the name face is the code to s/// if it is found (ie: :) , :( , *hug* ) Right now it's not s/// anything and just spits back the whatever you put in. If you type in "Hello there! :) " it prints it back instead of the emoticon.

Any ideas what I goofed?

I removed \b as suggested in the room but that didn't change the output. I tried removing \Q and \E but it errored out due to a quantifier problem since I have an emoticon face *crying*. THE SCRIPT: this is a basic chatterbox script, much like PM has, that let's people post messages to the site with each other.

####### # connecting to the DB again so we can filter emoticons ####### my $data = qq(SELECT id, name, location, face FROM emoticons); my $sth = $dbh->prepare($data); $sth->execute() or die $dbh->errstr; my ($id, $name, $location, $face); $sth->bind_columns(\$id, \$name, \$location, \$face); foreach my $line (reverse @keep) { my ($username, $message, $date, $ip) = split(/<!!>/, $line); while ($sth->fetch) { $message =~ s|\b\Q$face\E\b| <img src="$location" alt="$name"> | +gi; } if ($message =~ m|^/me|i) { $message =~ s|^/me||i; print qq(<b><i><a href="#" TITLE="Message sent on $date by $ip"> +$username</a></i></b> <i>$message</i><br>); } else { print qq(<b><a href="#" TITLE="Message sent on $date by $ip">$us +ername</a>:</b> $message<br>); } }


"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

In reply to substitutions with unknown data by sulfericacid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.