I'm kind of new To Perl so bare with my idiocy and the simplicity of this script. The script tests number successivly to be prime or not. I will include the script bellow. Everytime I re-define a variable it seems to use a new chunk of memory. Is there a way I can prevent this for both $Divider and $Number. Or at least make it release the previously used memory. The script run for about 3 minutes then it starts using swap space
Here It Is
#open(LOUTPUT,"lastoutput") or die "Unable To Open lastoutput File.
#Please Ensure That This File Exists And Contains On One Line. This Fi
+le
#Must Only Contain Numbers";
#$number=<LOUTPUT>;
$number=3;
#close(LOUTPUT);
$divisor = 2;
test();
sub test() {
# Un-Comment The Next Line For More Output
#print("NUM=$number DIV=$divisor\n");
if ($number / $divisor == int($number / $divisor)) {
# Number Is Prime
if ($number == $divisor) {
print("Prime $number\n");
# open(OUTPUT,">>output");
# print(OUTPUT "$number\n");
# close(OUTPUT);
}
# Number Is Not Prime
$divisor = 2;
$number = $number + 1;
}
$divisor = $divisor + 1;
#sleep(1);
test();
}
# open(LOUTPUT,">lastoutput");
# print(LOUTPUT "$number");
# close(LOUTPUT);
Sorry its got lots of comments but it can do more than I want it to do for testing any help is greatly apreciated.