#!/usr/bin/perl -w use strict; #Jabberwocky use Jabberwocky qw( $brillig @toves @borogroves @mome $son $vorpalSword $manxome $tumtumTree $Jabberwock $tulgeyWood $parent ); use Thread; =pod Author Lewis Carroll, translated to Perl by RMGir =cut =poem 'Twas brillig, and the slithy toves Did gyre and gimble in the wabe: =cut if($brillig->twas()) { foreach(@toves) { $_->gyre($wabe); $_->gimble($wabe); } } =poem All mimsy were the borogoves, And the mome raths outgrabe. =cut foreach(@borogroves) { die unless $_->mimsy(); } foreach(@mome) { $_->outgrabe(); } =poem "Beware the Jabberwock, my son! The jaws that bite, the claws that catch! Beware the Jubjub bird, and shun The frumious Bandersnatch!" =cut $parent->warn(<wield($vorpalSword); while(!$son->see($tumtumTree)) { $son->seek($manxome->foe()); } =poem And as in uffish thought he stood, The Jabberwock, with eyes of flame, Came whiffling through the tulgey wood, And burbled as it came! =cut sub bandersnatchWhiffle { $Jabberwock->has(EYES_OF_FLAME) or die; $Jabberwock->moveTo($tulgeyWood) do { $Jabberwock->whiffle(); $Jabberwock->burble(); } until($Jabberwock->see($son); } my $banderThread=new Thread \bandersnatchWhiffle; while($son->uffish() && !$son->see($Jabberwock)) { $son->think(); } $banderThread->join(); =poem One, two! One, two! And through and through The vorpal blade went snicker-snack! He left it dead, and with its head He went galumphing back. =cut for(1,2,1,2) { $son->sword()->slice($Jabberwock); $son->sword()->snickerSnack(); } die unless $Jabberwock->isDead(); $son->pickUp($Jabberwock->head()); $son->galumph($son->home()); =poem "And hast thou slain the Jabberwock? Come to my arms, my beamish boy! O frabjous day! Callooh! Callay!" He chortled in his joy. =cut $parent->chortle(<twas()) { foreach(@toves) { $_->gyre($wabe); $_->gimble($wabe); } } foreach(@borogroves) { die unless $_->mimsy(); } foreach(@mome) { $_->outgrabe(); }