Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

my @chickens

by pjf (Curate)
on Oct 04, 2001 at 06:33 UTC ( #116627=poem: print w/replies, xml ) Need Help??

I keep a few chickens in my backyard, and I think I once mentioned that I could code up chicken behaviour in half a page of perl. Well, my poetry is awful, but this compiles and runs happily with a standard perl distro.

Cheers,
Paul

use Carp qw/cluck/; my @chickens; sleep until $dawn; cluck $loudly until open $coop; exit $coop; chomp $food and accept($scraps,$seed); shift @straw, pop @eggs and cluck $more; until ($dusk) { seek($many,$worms,$bugs); join flock($other,@chickens) if split /from others/; tell WORLD,"sky is falling" if $airplane; } return 2,$coop and sleep until $dawn;

I can't believe I just posted that.

Replies are listed 'Best First'.
(MeowChow) Re: my @chickens
by MeowChow (Vicar) on Oct 05, 2001 at 07:15 UTC
      I did think of having a "chop $head and die" type verse, but I'm a vegetarian, and really have no desire to eat the poor chooks. So this was an intentional omission. :)

      Cheers,
      Paul

Re: my @chickens
by John M. Dlugosz (Monsignor) on Oct 04, 2001 at 08:18 UTC
    When you run it, it quits at the "exit" line near the top.

    I like it.

      Getting it to reach the exit is a little hard... "sleep until $dawn" tends to sleep a very long time indeed. ;) If only my real chickens would let me sleep in each morning.

      Thanks for the compliment. I'm glad it's been amusing.

      Cheers,

      Paul

Re: my @chickens
by blackjudas (Pilgrim) on Oct 04, 2001 at 22:37 UTC
    I think you've got an excellent imagination, and it compiles too :) ++.
Re: my @chickens
by FlashM (Novice) on Oct 07, 2001 at 09:07 UTC
    You're a nutcase... but I'm glad 'cos it made me laugh... thanks :)
Re: my @chickens
by Elliott (Pilgrim) on Oct 07, 2001 at 21:37 UTC
    After Great Perl Literature, how about Perl Movies?
    $batman=~s/\&//g; print "<A HREF=\"index.html\">Fly</A>"; print "<A HREF=\"javascript:opener.location.href=index.html\;self.clos +e\;\">"; sub marine{$paint="ffff00"} while($u){sleep} sub seattle{while(1==2){sleep}} $i="ffd700"; sub mummy{return} $shark{$colour}="0000ff"; my $love;undef $love; splice(my @best,$friend); $man[2]; @man=qw(grumpy sore indignant huffish bitter aggravated wrathful vexed + ireful enraged furious cross);
    Batman and Robin (Batman "and" robbing - ouch)
    Fly Away Home
    Home Alone
    Yellow Submarine
    While You Were Sleeping
    Sleepless in Seattle
    Goldeneye
    The Mummy Returns
    Blue Shark Hash
    Goodbye My Love
    My Best Friend's Wedding
    The Third Man
    Twelve Angry Men
      A large collection of Perl movies is already here.

      buckaduck

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: poem [id://116627]
Approved by root
help
Chatterbox?
[Corion]: choroba: Hmm - no, I keep the snippets inline, but as my framework also has support for capturing output etc., maybe I should do the same...
[Corion]: haukex: Yes, that approach is sane, and it heals the fragility of Pod parsers in a nice way while still syntax-checking stuff
[choroba]: Unfortunately, none of it is online
[haukex]: I figured that POD tests make sense, but only as author tests
[choroba]: I mean, the slides are, but not the makefile with scripts to create them
[Corion]: haukex: I've only now arrived at that revelation ;)
[Corion]: choroba: I use spod5, which also has that support, and also implements its own kinda-make stuff
[haukex]: But that module I just linked to assumes that most verbatim blocks are runnable code, I have other modules where that's not the case, so there I just copy-and-paste the synopsis into the author tests...
[haukex]: not the most efficient, but then again, I don't have that many modules on CPAN :-)
[Corion]: haukex: Yes, but if it's only supposed to run on my machine, I can be far more liberal with how I extract the code etc.

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2017-02-27 12:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (385 votes). Check out past polls.