Heh, cute. Of course, I couldn't help but simplify this, with a little help from CPAN.
#! /usr/bin/perl -w use strict; use Lingua::EN::Inflect qw/NUMWORDS ORD/; my @gift = ( 'this element purposely left blank', 'partridge in a pear tree', 'turtle doves', 'French hens', 'calling birds', 'golden rings', 'geese a-laying', 'swans a-swimmings', 'maids a-milkings', 'ladies dancing', 'lords a-leaping', 'pipers piping', 'drummers drumming', ); for my $day( 1..12 ) { print "On the ${\NUMWORDS(ORD($day))} day of Christmas,\nmy true l +ove gave to me,\n"; if( $day > 1 ) { print "${\NUMWORDS($_)} $gift[$_],\n" for reverse 2..$day; print 'and '; } print "a $gift[1].\n\n"; }
Of course all those plurals are just begging for Lingua::EN::Inflect::PL but I leave that an exercise to the reader...
Season's greetings to all the monks :o)
In reply to Re: Twelve Days of Christmas (with help from CPAN)
by grinder
in thread Twelve Days of Christmas
by ibanix
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |