Sure it works. Your code is incomplete, though, so I'll just guess that you don't actually have a $ in your input string. You are probably interpolating an uninitalized variable in your string. Using warnings and strict should have cought that. Also "is not working" is not really a good description of an error. It's always doing
something - it just doesn't do what you expect:
#!/usr/local/bin/perl -w
use strict;
my $string = 'begin$end';
$string =~ s/\$/tmp/g;
print "$string\n";
output:
begintmpend
See also
strict,
warnings and try searching for "interpolated" in
perldata.