Hi
tcarmeli,
Sure, why not declare the hash outside of the subroutine, so that its scope doesn't cause it to be garbage-collected? You're obviously not using the hash anyway:
#!/usr/bin/perl -w
use strict;
use warnings;
my $func_done;
my $func_return;
my $max=1000000;
my %myhash;
DoIt($max);
$func_return = (times)[0];
printf "Size of myhash is %d\n", 0 + keys %myhash;
printf "Return took %.4f CPU seconds\n", $func_return - $func_done;
sub DoIt{
my $limit=shift;
my $i;
foreach $i (0..$limit){
$myhash{$i}=1;
}
$func_done = (times)[0];
return;
}
But it sounds like you may have an XY problem. What is your real goal here?
s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/