cLive ;-) has asked for the wisdom of the Perl Monks concerning the following question:
This is a silly example, because it always loops. But the point is, it only loops for 2 seconds then quits.my $count = time; $_ = 'hello there'; while (/e/) { print "ooo, looping\n"; die ('infinite loop') if ($count + 2 > time); }
In real life, I'll be doing dynamic s/earch/replace/ on dynamic vars, where the match differs from the replace (amongst other things), and wondered what the most efficient way was of catching this very rare, but possible, issue.
I suppose, the question I want answered is "What kind of failsafe's do you use to catch possible infinite loops?"
cLive ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Catching Infinite Loops
by tadman (Prior) on Apr 20, 2001 at 08:43 UTC | |
by Rhandom (Curate) on Apr 20, 2001 at 09:24 UTC | |
|
Re: catching infinite loops
by larsen (Parson) on Apr 20, 2001 at 12:48 UTC | |
|
Re: catching infinite loops
by kal (Hermit) on Apr 20, 2001 at 12:36 UTC | |
by tilly (Archbishop) on Apr 20, 2001 at 16:04 UTC | |
|
Re: catching infinite loops
by virtualsue (Vicar) on Apr 20, 2001 at 15:58 UTC | |
by cLive ;-) (Prior) on Apr 20, 2001 at 23:38 UTC | |
by tilly (Archbishop) on Apr 21, 2001 at 08:12 UTC | |
|
Re: catching infinite loops
by cLive ;-) (Prior) on Apr 20, 2001 at 08:23 UTC |