my $new_string = testing_string($string); sub testing_string { my $content = $_[0]; #string copy, expensive # do some stuff $content =~ s/a/b/sg; return $content; #string copy, expensive }