I'm trying to write a small Perl script which needs to add sleep time in order to delay the execution commands in the for loop.
here is the example.
use strict;
use warnings;
use v5.26.1;
my $delay = 10;
my $num = 100;
for (my ($i, $d) = (1, $delay); $i <= $num; $i++, $d+=5 ) {
say "delaying iteration $i by $d";
sleep($d);
}
The output is very simple too
delaying iteration 1 by 10
delaying iteration 2 by 15
delaying iteration 3 by 20
delaying iteration 4 by 25
delaying iteration 5 by 30
But I have to increase the sleep time for every 5th iteration example should be like below
First 5 lines should be delayed with out sleep time like this
delaying iteration 1 by 0
delaying iteration 2 by 0
delaying iteration 3 by 0
delaying iteration 4 by 0
delaying iteration 5 by 0
The next 5 lines should be delayed with 5 seconds sleet time like this
delaying iteration 6 by 5
delaying iteration 7 by 5
delaying iteration 8 by 5
delaying iteration 9 by 5
delaying iteration 10 by 5
And then every 5 iterations the sleep time should increase with 5 seconds.
delaying iteration 11 by 10
delaying iteration 12 by 10
delaying iteration 13 by 10
delaying iteration 14 by 10
delaying iteration 15 by 10
Can someone please advise on how to get it working that way?