in reply to Re: s/// with asterisks and other chars
in thread s/// with asterisks and other chars

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.

  • Comment on Re^2: s/// with asterisks and other chars

Replies are listed 'Best First'.
Re^3: s/// with asterisks and other chars
by Roy Johnson (Monsignor) on Nov 01, 2005 at 20:34 UTC
    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.