Public Scratchpad | Download, Select Code To D/L |
Making sure my terminal is still connected, I use this:
But that eats a lot of system resources for something so simple...#!/usr/bin/perl use strict; use warnings; my $now = time; while (1) { $now = time; if (($now % 5) == 0) { system "date"; while (($now % 5) == 0) { $now = time; } } }
is a lot more elegant... Thanks, jwest! "Sleep" was the big thing I was missing...#!/usr/bin/perl use strict; use warnings; my $seconds = 5; while (1) { my $time = localtime(); print $time, "\n"; sleep $seconds; }