in reply to Re^2: How to replace '$' in strings
in thread How to replace '$' in strings

Even simpler: use the special regex delimiter ' (single quote) to suppress interpolation:

#! perl use strict; use warnings; my $string = 'i am us$ing moni$ka expressi$on'; $string =~ s'\$'\$'g; print $string, "\n";

Output:

23:12 >perl 1483_SoPW.pl i am us\$ing moni\$ka expressi\$on 23:14 >

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^4: How to replace '$' in strings
by soonix (Chancellor) on Dec 15, 2015 at 09:33 UTC
    special regex delimiter ' (single quote) to suppress Interpolation

    Thanks for the tip, nice to learn something new(*).

    For others: This is not in perlre, but under Regexp Quote Like Operators in perlop.

    (*) "new" to me, of course :-)