#! /usr/bin/perl -wl
# mytime2+ script.
# Tim Maher, tim@TeachMePerl.com, www.MinimalPerl.com
# Improvement to mytime2, from p. 215 of Minimal Perl book.
(undef, $minute, $hour)=localtime ; # leave seconds undefined
#=====> Convert military time to "civilian" time <=====#
$am_pm='AM';
$hour >= 12 and $am_pm='PM'; # hours 12-23 are afternoon
$hour > 12 and $hour=$hour-12; # 13-23 ==> 1-11 (PM)
$hour == 0 and $hour=12; # convert day's first hour
$minute < 10 and $minute="0$minute"; # convert "5" to "05", etc.
print "The time is $hour:$minute $am_pm.";
# 00 1 2 3 4 5 6 7 8 9 10 11 / 12 13 14 15 16 17 18 19 20 21 22 23