Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: Twelve Days of Christmas (with help from CPAN)

by TheDamian (Priest)
on Dec 14, 2002 at 04:31 UTC ( #219819=note: print w/ replies, xml ) Need Help??


in reply to Re: Twelve Days of Christmas (with help from CPAN)
in thread Twelve Days of Christmas

Very nice. But still not Lazy enough. ;-)

Try this:

use Lingua::EN::Inflect qw/inflect NUM PART_PRES/; use Lingua::Conjunction qw/conjunction/; my @gift = ( '', 'partridge in a pear tree', 'turtle dove', 'French hen', 'calling bi +rd', 'gold ring', 'goose', 'swan', 'maid', 'lady', 'lord', 'piper', 'drummer', ); my @action = map {$_ && PART_PRES $_} ( '', '', '', '', '', '', ' a-lay', ' a-swim', ' a-milk', ' dance', ' a-leap', ' pipe', ' drum', ); for my $day( 1..12 ) { print inflect("On the NUMWORDS(ORD($day)) day of Christmas,\n"), "my true love gave to me:", conjunction( map { NUM($_); inflect "\n\tA(PL_N($gift[$_]))$action[$_]"} reverse 1..$day ), ".\n\n"; }

Which then makes it easy to change it to:

use Lingua::EN::Inflect qw/inflect NUM PART_PRES/; use Lingua::Conjunction qw/conjunction/; my @gift = ( '', 'Swiss Army switch statement', 'style of OO', 'loop type', 'sigil fix', 'catch block', 'junction', 'ref', 'sub', 'type', 'try', 'function', 'less-than', ); my @action = map {$_ && PART_PRES $_} ( '', '', '', '', '', '', ' OR', ' a-bind', ' overload', ' a-check', ' a-catch', ' curry', ' chain', ); for my $apo ( 1..12 ) { print inflect("In the NUMWORDS(ORD($apo)) Perl Apocalypse,\n"), "my Larry gave to me:", conjunction( map { NUM($_); inflect "\n\tA(PL_N($gift[$_]))$action[$_]"} reverse 1..$apo ), ".\n\n"; } ;-)


Comment on Re: Re: Twelve Days of Christmas (with help from CPAN)
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://219819]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2014-07-11 23:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (236 votes), past polls