in reply to Help to infinite loop

You don't say what platform you're on, so I can't give you too specific help, but maybe you should look at the alarm function. http://perldoc.perl.org/functions/alarm.html

instead of sleeping, and calling a sub to stop the loop, write the loop like this (pseudocode):

while (!alarmed) { yourWorkHere(); alarm("you have 60 sec. to press a key to stop this loop"); if (keyPressed) { alarmed=1; } }