in reply to Running code a certain amount of time

Ninth Prince,
The example by ccn allows you to stop execution at almost any arbitrary point. What you haven't explained is what is going on inside the loop. Signals changed in 5.8 IIRC, so knowing if you want safe or unsafe signals is only something you can answer. There is an alternative if you want the code to exit the loop before starting the next loop (not anywhere in the middle of the loop).
my $limit = time + 3_600; my $cnt; while (1) { ++$cnt; last if $cnt > 100 || time > $limit; # rest of your loop }

Cheers - L~R