use Storable( retrieve, store) my $string = getString($ARGV[]); ENDING MY TIMER sub getString{ my ($file1, $file2) = @_; my @thisarray = @{retrieve($file1)}; # size ~ 20M my %thishash = %{retrieve($file2)}; # size ~ 5M my $thisString; # here I am doing something # to create a $thisString and its size is less than 100K STARTING MY TIMER return $thisString; }