my $hour = int (time / 3600) % 12; $hour = 12 if ! $hour; # if 0 should be 12