testing_string(\$string); #send a reference to $string instead of $string sub testing_string { my $contentref = $_[0]; # do some stuff $$contentref =~ s/a/b/sg; }