in reply to Improve my coding
I'd also declare the variables I only used in the body of the loop in the body, and I wouldn't make them global. Furthermore, if I were to make constants pi and 2pi, I'd define the latter as a function of the first:for (my $r = 1; $r <= 100; $r += 2) { ... }
If you then use a better approximation of pi, you'd only have to update the program once.$twopi = 2 * $pi;
|
|---|