in reply to Print Interval Instead of Timestamp

Do you mean you want your timestamps to go from something like 0:05 ... 0:55..1:00 ...1:10...2:05... etc etc? How would you know the exact time it actually ran if you impose an artificial timestamp on it?

Would a loop work?

#!/usr/bin/perl use strict; use warnings; my $hour = 0; my @mins = ('00','05','10','15','20','25','30','35','40','45','50','55 +'); for my $hour (0..23){ for (1..12 ){ print $hour.':'.$mins[0],"\n"; push (@mins,shift(@mins)); #go round the clock } }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: Print Interval Instead of Timestamp
by frozenwithjoy (Priest) on Jul 06, 2012 at 16:29 UTC

    Another approach would be to make a simple subroutine that rounds the time down to the nearest 5-minute mark. This would be a lot easier to maintain (and change the interval, if desired). It would basically go something like this:

    1. adjust minute value by adding seconds / 60
    2. use Math::Round to round down to the nearest multiple of choice (use a variable instead of 5 to make it easily customizable):
    3. $minutes_binned = nearest_floor( 5, $minutes_floating );
    4. return binned minute