C:\Users\Andy\Documents>perl test.pl Length of string: 101000000 Time taken was 0 wallclock secs ( 0.17 usr 0.03 sys + 0.00 cusr 0.00 csys = 0.20 CPU) seconds Time taken was 1 wallclock secs ( 1.13 usr 0.03 sys + 0.00 cusr 0.00 csys = 1.16 CPU) seconds C:\Users\Andy\Documents> #### my $new_string = testing_string($string); sub testing_string { my $content = $_[0]; # do some stuff $content =~ s/a/b/sg; return $content; } #### # do stuff here my %test_var; $test_var{$string} = $string; testing_string(); $string = $test_var{$string}; sub testing_string_2 { # do some stuff here $test_var{$string} =~ s/a/b/sg; }