use strict; use warnings; my $string = '123!'; my $new_string = $string =~ s/!/4/r; print "original - $string\nreplacement - $new_string";