in reply to s/// with asterisks and other chars

The faces are not at word boundaries. You should probably remove the \bs from that expression. Unlike badwords, emoticons are not words. Things like " *" are not word boundaries (where letters and non-letters meet).

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: s/// with asterisks and other chars
by froglover (Initiate) on Nov 01, 2005 at 19:40 UTC
    I admit, I did overlook the \b but that wasn't the only problem. I removed them only leaving \Q$var\E and it's not catching on yet.

    Thank you.

      This little excerpt should be a fair proof that the basic idea works:
      my $message = 'one :-* smiley'; my ($face, $location, $name) = (':-*', 'here', 'smoochie'); $message =~ s/\Q$face\E/ <img src="$location" alt="$name"> /gi; print $message, "\n";
      Now what you need to do is figure out how your situation differs. That means putting in print statements so you can see what's really going on every step of the way, and then examining the output for what wasn't what you expected it to be. Start by replacing your if-face-block with something like
      if ($face) { if ($message =~ s/\Q$face\E/ <img src="$location" alt="$name"> + /gi) { print "Substituted for [$face] in [$message]\n"; } else { print "[$face] was not found in [$message]\n"; } } else { print "$face was not true!\n"; }
      That way, you get a definite indication of what path things took and what your variables were. Something will probably jump out at you.

      Caution: Contents may have been coded under pressure.