I'd like to offer up a small conversion to make this web-based. I'm not sure how well it would perform on a low bandwidth connection, but running off my local web server it works quickly enough to completely refresh and complete the request every second. Good stuff, ++hiseldl!
#!perl
$|=1;
$w = 25;
$h = 25;
$img="."x($w*$h-1);
substr($img,11*$w+12,1,"#"); # in the middle
$,="\n";
@hour=split//,"Just";
@min =split//,"another";
@sec =split//,"Perl hacker";
print "Content-type: text/html\n\n";
print "<pre>";
@t = localtime;
$_=$img;
for $hidx(0..3) {
$newx=newx($t[2]%12*30+180,0,2+$hidx)+12;
$newy=newy($t[2]%12*30+180,0,2+$hidx)+11;
$vx = sprintf("%d", $newx);
$vy = sprintf("%d", $newy);
substr($_,$vy*$w+$vx,1,$hour[$hidx]);
}
for $midx(0..$#min) {
$newx=newx($t[1]*6,0,-4-$midx)+12;
$newy=newy($t[1]*6,0,-4-$midx)+11;
$vx = sprintf("%d", $newx);
$vy = sprintf("%d", $newy);
substr($_,$vy*$w+$vx,1,$min[$midx]);
}
for $sidx(0..$#sec) {
$newx=newx($t[0]*6,0,-1-$sidx)+12;
$newy=newy($t[0]*6,0,-1-$sidx)+11;
$vx = sprintf("%d", $newx);
$vy = sprintf("%d", $newy);
substr($_,$vy*$w+$vx,1,$sec[$sidx]);
}
print (/.{$w}/g),scalar localtime;
print '<meta http-equiv="refresh" content="1;url=">';
sub newx {
my($ang,$x,$y) = @_;
my $a=$ang * atan2(1,1)/45;# angle in radians
return
($x)*cos($a) - ($y)*sin($a);
}
sub newy {
my($ang,$x,$y) = @_;
my $a=$ang * atan2(1,1)/45;# angle in radians
return
($x)*sin($a) + ($y)*cos($a);
}
exit 0;