First of all, most operating systems already
have services for scheduling program runs. UNIX has
the cron program and Windows NT has the
AT program and service. Look first into these
before you think of rolling your own.
If you still want to roll your own, look
into the sleep() function
call, which will put your script to sleep for
the amount of time you specify. Note that running
such a script on a server without the administrators
knowledge could have bad consequences for you. First
talk to your admin and think if using cron
would do the job for you as well.
Here is a small program that prints
a line every 10 seconds (tested) :
#!/usr/bin/perl -w
use strict;
my $tick = "tick\n";
# loop until this process is terminated from the outside
while (1) {
print $tick;
# Make "tick" into "tock" and "tock" into "tick"
$tick =~ tr/io/oi/;
# sleep 10 seconds
sleep( 10 );
}