in reply to Finding $ character

'just try this \Q is for convert special character to Normal character
$a = '$priyal'; $a =~ s/\Q$\E/tmp/g; print $a; o/p:tmppriyal
Regards, Gubendran.L

Replies are listed 'Best First'.
Re^2: Finding $ character
by ambrus (Abbot) on Dec 28, 2004 at 23:28 UTC

    This is plain wrong. It just can't work. Did you try it before posting? Do you know what \Q is for? (It's for escaping regexp metacharacters from strings interpolated in regexen.)

    From perlop, section Quote and Quote-like Operators:

    You cannot include a literal "$" or "@" within a "\Q" sequence. An unescaped "$" or "@" interpolates the corresponding variable, while escaping will cause the lit- eral string "\$" to be inserted. You'll need to write something like "m/\Quser\E\@\Qhost/".
Re^2: Finding $ character
by Aristotle (Chancellor) on Dec 28, 2004 at 23:27 UTC

    It doesn't produce that output when I run it. In fact it doesn't change the string at all. Did you actually test it?

    Makeshifts last the longest.