#!/usr/bin/perl use warnings; use strict; my @gifts = <DATA>; my @days = qw(1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th 11th 12th); my @dayspast; while(@days){ my $day = shift @days; push @dayspast, $day; my ($num) = $day =~ /(\d+).*/; print "On the $day day of Christmas,\nMy true Perl gave to me\n"; foreach my $gift (reverse @dayspast){ my ($n) = $gift =~ /(\d+).*/; print $gifts[$n - 1]; } print "\n"; if(scalar @dayspast == 1) {$gifts[0] = 'And '.$gifts[0]} } exit; __DATA__ a commandline in an @ARGV 2 sca-lars 3 ar-rays 4 nested hash 5 ENCODED STRINGS 6 threads-a-spawning 7 procs-a-forking 8 tests succeeding 9 modules loading 10 objects blessing 11 signals catching 12 saints-a-drinking
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: 12 Days of Christmas
by McDarren (Abbot) on Dec 15, 2005 at 01:11 UTC | |
by zentara (Cardinal) on Dec 15, 2005 at 12:10 UTC | |
Re: 12 Days of Christmas
by petdance (Parson) on Dec 16, 2005 at 16:51 UTC | |
Re: 12 Days of Christmas
by zentara (Cardinal) on Dec 16, 2005 at 17:35 UTC | |
Re: 12 Days of Christmas
by zentara (Cardinal) on Dec 19, 2005 at 18:58 UTC |