# hexclock.pl : # Display current time in various formats. # # b zero padded binary integer # c ASCII character # d signed integer # e exponential notation floating point # f decimal notation floting point # o octal integer # p pointer to memory address where time is stored (non-dynamic) # u unsigned integer # x hexadecimal integer (default) use strict; my $fmt = shift ||'x'; $fmt='x' unless ($fmt =~ /[bcdefgopu]/) ; $fmt = "%02$fmt" if ($fmt =~ /[xodu]/) ; $fmt = "%06$fmt" if ($fmt =~ /b/); $fmt = "%0$fmt" if ($fmt !~ /%/); while (1) { my ($h,$m,$s) = split ":",`date +%H:%M:%S:`; printf "\r$fmt : $fmt : $fmt", $h, $m, $s; sleep 1; }