A Working Poem (in Perl)

A popular Christmas la-di-da rewritten in the Perl programming language. What makes this different to other poems is that it actually produces useful output, although only if you run this poem at night. In case you don't speak fluent Perl (most people will soon discover that do they speak some), the original verse is shown below. 
#!/usr/bin/perl
$flock="Baah!";
$shepherds{'watched'}=$flock;
while($shepherds{'watched'} eq $flock && bynight()){
  $shepherds{'seated'}='ground';
  $angel_of_the_lord--;
  foreach(@around){$_=$glory{'shone'};}
  if($shepherds{'troubled_mind_seized'}){
    print "Fear not\n" if $mighty_dread;
  }
  @mankind=qw/You Everybody/;
  foreach $person(@mankind){
    print "$person! Glad tidings of great joy I bring.\n";
  }
  $flock="Baaaah?";
}
sub bynight{
  ($s ,$m ,$hour)=localtime(time);
  1 if $hour>19 || $hour<6;
}

How do I get this poem to work?

  • You need to have Perl installed on your computer. Get a good version from www.activestate.com if you don't have it yet. There is even a version for the Windows O/S.
  • Copy the code into a file called, say, xmas.pl
  • At night, around Christmas time, run the file using the command: perl xmas.pl, and voila - a working poem!

What the hell does this poem do?

Well, in addition to inspiring you with the joys of Christmas, it works as follows:

If you run it between the hours of 7pm and 6am (remember, this Christmas thing happened at night), the seated shepherds experience a big light and get very worried. They get told not to stress and are told that they (and everyone else) have just won the spiritual lottery. Meanwhile, the sheep are the only ones questioning the feasibility of all this. 

The original words by Nahum Tate

(And melody by Georg Friedrich Händel)
While shepherds watched their flocks by night,
All seated on the ground,
The angel of the Lord came down,
And glory shone around,
And glory shone around.

“Fear not!” said he, for mighty dread
Had seized their troubled mind.
“Glad tidings of great joy I bring
To you and all mankind
To you and all mankind.


Credit goes to the anonymous person who came up with the original idea. More of this linguistic malarky can be found on http://www.perlmonks.org/index.pl?node=Perl%20Poetry