Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env perl
use strict;
use Roman;
my @time = localtime;
my @result;
my $hours = $time[2];
my $past = $hours > 11 ? "noon" : "midnight";
$hours %= 12;
add($hours, "hour");
add($time[1], "minute");
add($time[0], "second");
print "At the tone, the time will be... ";
if (@result) {
print shift @result, ", " if @result > 2;
print shift @result, " and " if @result > 1;
print shift @result;
print " past $past";
} else {
print "exactly $past";
}
print "... beep!";
sub add {
my ($count, $label) = @_;
if ($count > 1) {
push @result, Roman($count) . " ${label}s";
} elsif ($count == 1) {
push @result, Roman($count) . " $label";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.