A.1 Answers for Chapter 2A.1.1 Exercise 1 (Section 2.10.1)Here's one way to do it. First, start with the package directive and use strict: package Oogaboogoo::date; Then define the constant arrays to hold the mappings for day-of-week and month names: my @day = qw(ark dip wap sen pop sep kir); Next, define the subroutine for day-of-week-number to name. Note that this subroutine will be accessible as Ooogaboogoo::date::day: sub day { Similarly, you have the subroutine for the month-of-year-number to name: sub mon { Finally, the mandatory true value at the end of the package: 1; Name this file date.pl within a directory of Oogaboogoo in one of the directories given in your @INC variable, such as the current directory. A.1.2 Exercise 2 (Section 2.10.2)Here's one way to do it. Pull in the .pl file from a place in your @INC path: use strict; Then get the information for the current time: my($sec, $min, $hour, $mday, $mon, $year, $wday) = localtime; Then use the newly defined subroutines for the conversions: my $day_name = Oogaboogoo::date::day($wday); The year number is offset by 1900 for historical purposes, so you need to fix that: $year += 1900; Finally, it's time for the output: print "Today is $day_name, $mon_name $mday, $year.\n"; |