CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [Lynn] Using Counter: Edit Log



Laurent_R
Veteran / Moderator

Sep 21, 2012, 9:31 AM


Views: 2097
Re: [Lynn] Using Counter

Lynn, there might still be a small error in the code after the correction suggested earlier.


Code
 for ($l = 0; $l<=$RUNS; $l++)


looks like a possible error because if $RUNS equals 10, you will run 11 tiBesides mes through the for loop, which is likely to be different from what you want.

Besides, on a purely stylistic point of view, you might consider a more "perlish" syntax.

The code above is better rewritten as:


Code
 for $l (0..$RUNS) {


or, better (but no longer exactly equivalent):

Code
 for my $l (0..$RUNS) {


as it is simpler and more idiomatic and it runs faster (it is equivalent to the above, so it has the same bug if your code had the possible I mentioned.

In fact, since you do not seem to use $l in your loop, it could be even further simplified by dropping $l altogether:


Code
 for (0..$RUNS) {



(This post was edited by Laurent_R on Sep 21, 2012, 9:35 AM)


Edit Log:
Post edited by Laurent_R (Veteran) on Sep 21, 2012, 9:35 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives