Blob


1 #!/usr/bin/perl
3 # The Oogaboogoo natives on the island have unusual names for the days and
4 # months. Here is some simple but not very well-written code from Gilligan.
5 # Fix it up, add a conversion function for the month names, and make the
6 # whole thing into a library. For extra credit, add suitable error checking
7 # and consider what should be in the documentation.
8 #
9 # @day = qw(ark dip wap sen pop sep kir);
10 # sub number_to_day_name { my $num = shift @_; $day[$num]; }
11 # @month = qw(diz pod bod rod sip wax lin sen kun fiz nap dep);
13 use v5.24;
14 use warnings;
15 use strict;
16 use utf8;
18 package Oogaboogoo;
20 my @day = qw(ark dip wap sen pop sep kir);
21 my @month = qw(diz pod bod rod sip wax lin sen kun fiz nap dep);
22 sub number_to_day_name {
23 my $num = shift @_;
24 die "Invalid day number" if $num >= 7 or $num < 0;
25 $day[$num];
26 }
27 sub number_to_month_name {
28 my $num = shift @_;
29 die "Invalid month number" if $num >= 12 or $num < 0;
30 $month[$num];
31 }
32 1;