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

[FWP] A major screw-up: infinite loop



I guess you can say that  Perl had fun with me. For clarity, this
bug has already been solved, and I think it is a bug that is unique
to Perl, and something that makes a clever novice-level puzzle.

I was writing a program that used a library of simple functions I
wrote in order to simplify some operations. The library was stored
in a completely different part of the hard drive than the script I was
writing. The library was stored with the other Perl 5 libraries.

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.

To narrow things down for you, the problem is not with the sub
"&getadatestringfromsomewhere()", since I just made that up for
simplicity.

I believe you have enough info to make at least an educated guess. Once
you
see the answer, it becomes obvious. But I will let anyone with
sufficient time
on their hands to make some guesses before I post my answer. I fear that

I may have made this problem *too* simple. Oh, well. It's my first post
to this
list.

Paul King



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