[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] A major screw-up: infinite loop



Paul King wrote:
> The main part of my program consisted of an outer loop:
> 
> $upper = 2048;
> for  ($i = 1; $i <= $upper; $i ++) {
>    $date = &getadatestringfromsomewhere();
>    $my_date = &parseDate($date); # return a different date format
> }
> 
> This loop never got as far as 2048. In fact, it looped 
> infinitely at $i = 13, after processing $i = 1 only once,
> and skipping $i = 2 to 12. This had me stumped for the
> better part of two days.

Let me guess -- you didn't use scope-local (i.e. 'my') variables, and
parseDate() clobbered on your global variable $i?

You *did* run this program with both -w and 'use strict;'?

Cheers,
Philip

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe