in reply to Mock my code!
open PRIMES, $primefile; while(<PRIMES>) { push (@parray, $_); } close PRIMES; # could be open PRIMES, $primefile; @parray = <PRIMES>; close PRIMES;
Simple conditionals can be written as Masem pointed out. As well if you the unless you can take advantage of the fact that the result from $lowrange % 2 will be enough to tell TRUE or FALSE (1 or 0) without the additional '==' test.if($lowrange % 2 == 0) { $lowrange++; } # could be $lowrange++ unless ($lowrange % 2);
Also another note on prints: When you have something like
You can use a single printprint "\nTotal amount of primes: $counter \n"; print "Your results have been saved, starting with ".$path.$beginloc.$last."\n\n";
Also you can use the variables inside the double quotes:print "\nTotal amount of primes: $counter \n", "Your results have been saved, starting with ".$path.$beginloc.$last."\n\n";
The curly braces are not always required but they can alleviate some possible headaches.print "Your results have been saved, starting with ".$path.$beginloc.$last."\n\n"; # becomes print "Your results have been saved, starting with ${path}${beginloc}$ +{last}\n\n";
Just a few notes for ya.
|
|---|