in reply to enforce timeout in loop
Follow the example in the perldoc page for alarm. Change your for loop to look like:
foreach my $sleepval (@sleepvals) { eval { local $SIG{ALRM} = sub { die }; alarm 3; sleep($sleepval); }; print strftime "%H:%M:%S", localtime; print "\n"; }
In Section
Seekers of Perl Wisdom