my $str = '1.2.3.4.5'; $str =~ tr/./_/; # No need to escape '.' print $str;