You could use an event loop, like this Glib example..... the trick is to return 0 or 1 to keep the timer going or to stop it. You could get very creative , depending on what code you need to run..... just fork and exec your code off, and let the timer do the checking for 7 to 7 in time.
#!/usr/bin/perl
use warnings;
use strict;
use Glib;
my $main_loop = Glib::MainLoop->new;
my $count = 1;
my $timer = Glib::Timeout->add (1000, \&timer_callback, undef, 1 );
#1000 milliseconds = 1 second
sub timer_callback{
$count++;
# are we between 7 and 7?.... if so....(code left up to you)
print "$count\n";
return 1; #return 1 to keep going, return 0 to stop timer
}
my $count1 = 1;
my $timer1 = Glib::Timeout->add (100, \&timer1_callback, undef, 1 );
sub timer1_callback{
$count1++;
print "\t$count1\n";
return 1;
}
### filehandle watch
#open (FH, "+> test.log") or warn "$!\n";
#Glib::IO->add_watch (fileno 'FH', ['in'], \&watch_callback, 'FH', 1 )
+;
$main_loop->run;