I am quite new to Perl and this is my first post here so be gentle.
I am using real time in a countdown timer of 60 seconds and need to be able to stop it every 10 s
Update $end_time after getting the response from the user.
while (1) {
$countdown--;
$time = time;
last if ($time >= $end_time);
printf("\r%02d:%02d:%02d",
($end_time - $time) / (1*60),
($end_time - $time) / 60%60,
($end_time - $time) % 60,
);
sleep(1);
if ($countdown%10 == 0) {
print "Continue? ";
$answer = <>;
chomp $answer;
last if $answer ne 'y';
$end_time = time + $countdown;
}
}