$text = 'this has a $foo in it and a $bar'; $text =~ s/(\$\w+)/$1/eeg; # needs /ee, not /e #### #!/usr/bin/perl -wT use strict; no strict 'refs'; my $foo = 'switch'; my $bar = 'button'; my $text1 = my $text2 = my $text3 = 'this has a $foo in it and a $bar'; $text1 =~ s/(\$\w+)/$1/g; $text2 =~ s/(\$\w+)/$1/ge; $text3 =~ s/(\$\w+)/$1/gee; print "T1 /g : $text1\n"; print "T2 /ge : $text2\n"; print "T3 /gee : $text3\n"; =OUTPUT T1 /g : this has a $foo in it and a $bar T2 /ge : this has a $foo in it and a $bar T3 /gee : this has a switch in it and a button