use strict; use warnings; my @prefix = ( 'first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth', ); my @gifts = ( 'a partridge in a pear tree', 'two turtle doves', 'three French hens', 'four calling birds', 'five golden rings', 'six geese a-laying', 'seven swans a-swimmings', 'eight maids a-milkings', 'nine ladies dancing', 'ten lords a-leaping', 'eleven pipers piping', 'twelve drummers drumming', ); my $once = 1; sub todays_gifts { my $day = shift(@_); print "On the $prefix[$day-1] of Christmas\,\n"; print "My true love gave to me\, \n"; do { if ($once && $day == 1) { print "$gifts[$day-1].\n\n"; $once-- +; return; } if ($day == 1) { print "and $gifts[$day-1].\n\n"; return; } print "$gifts[$day-1],\n"; $day--; } while ($day >= 1); print "\n"; } for (1..12) { todays_gifts $_; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Twelve Days of Christmas (with help from CPAN)
by grinder (Bishop) on Dec 13, 2002 at 17:02 UTC | |
by TheDamian (Vicar) on Dec 14, 2002 at 04:31 UTC | |
by ibanix (Hermit) on Dec 13, 2002 at 17:10 UTC | |
Re: Twelve Days of Christmas
by Mr. Muskrat (Canon) on Dec 13, 2002 at 16:38 UTC | |
by ibanix (Hermit) on Dec 13, 2002 at 16:46 UTC | |
Re: Twelve Days of Christmas
by cecil36 (Pilgrim) on Dec 16, 2002 at 15:02 UTC | |
Re: Twelve Days of Christmas
by jmcnamara (Monsignor) on Dec 19, 2002 at 12:17 UTC | |
Re: Twelve Days of Christmas
by frankus (Priest) on Dec 19, 2002 at 11:42 UTC |