sub dot_to_underscore { $_[0] =~ s/\./_/g; } my $string = 'hello.world'; print "$string\n"; dot_to_underscore($string); print "$string\n";