#!/usr/bin/perl
# Time-stamp: "2005-08-19 01:26:51 ADT"    sburke@cpan.org
#
# desc{  every few seconds (default: 3), clears the screen and runs a command. }
#
# e.g.:
#  refreshing -10 'ps x'
#  refreshing 'w'

my $clear = `clear`; # get clear-screen sequence

my $delay;
if(@ARGV > 1 and $ARGV[0] =~ m<^-([0-9]+)$>s) {
  $delay = $1;
  shift @ARGV;
} else {
  $delay = 3;
}

die "No command to run?" unless @ARGV == 1;

my $command = shift @ARGV;
$| = 1;
while(1) {
  print $clear, scalar(localtime), " % $command\n\n";
  system($command);
  sleep $delay;
}
exit;
