Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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";
- }
- }
Add Comment
Please, Sign In to add comment