I thought I'd try my hand at perl poetry, and what better place to start with than Lewis Caroll's Jabberwocky.

Of course, before posting, I thought I'd check if someone else already did this here, and sure enough, wombat did. (Edit: And andreychek also. Nice use of fork!)

My approach is different from theirs, though, so I figured I'd post this anyways.

#!/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(<<WARNING); "Beware the Jabberwock, my son! The jaws that bite, the claws that catch! Beware the Jubjub bird, and shun The frumious Bandersnatch!" WARNING =poem He took his vorpal sword in hand: Long time the manxome foe he sought--- So rested he by the Tumtum tree, And stood awhile in thought. =cut $son->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(<<FRABJOUS); And hast thou slain the Jabberwock? Come to my arms, my beamish boy! O frabjous day! Callooh! Callay! FRABJOUS =poem 'Twas brillig, and the slithy toves Did gyre and gimble in the wabe: All mimsy were the borogoves, And the mome raths outgrabe. =cut if(brillig->twas()) { foreach(@toves) { $_->gyre($wabe); $_->gimble($wabe); } } foreach(@borogroves) { die unless $_->mimsy(); } foreach(@mome) { $_->outgrabe(); }
Note that Jabberwocky.pm is left as an exercise to the reader :)

--
Mike

In reply to Jabberwocky, by Lewis Caroll by RMGir

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.