Question: I am new to Perl. How do I create a a loop that runs until the current time is a multiple of 5 seconds?

Answer: 
If you just want to suspend your process until the seconds are a multiple of 5, then you can use the [`Time::HiRes`](https://metacpan.org/pod/Time::HiRes) module like this

```
use Time::HiRes qw/ gettimeofday usleep /;

my ($s, $us) = gettimeofday;
my $delay = 1_000_000 * (5 - $s % 5) - $us;
usleep $delay;

# Do stuff

```

or if you want to execute some code until the next multiple of 5 seconds then use this

```
use Time::HiRes qw/ gettimeofday tv_interval /;

my $t1 = [ gettimeofday ];
$t1->[0] += 5 - $t1->[0] % 5;
$t1->[1] = 0;

while ( tv_interval([ gettimeofday ], $t1) > 0 ) {
  # Do stuff
}

```
Borodin's answer is what you want if you really need the seconds to be a multiple of five. However, is it possible you just want to implement five second delays in your program? If so:

```
sleep 5;

```