Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Macaroni and Cheese

by Ovid (Cardinal)
on Sep 04, 2000 at 22:37 UTC ( #31023=poem: print w/replies, xml ) Need Help??

One of the exercises that you often receive in beginning programming classes is to write a recipe in such detail that a computer would understand, if it could understand your native language. Of course, this isn't possible, so I decided to make the task a bit easier for the computer.
#!/usr/bin/perl -w use strict; use Carp; use vars qw($pleasure $I $lunch); my %ingredient = ( butter => '1/4 cups', milk => '1/4 cups', macaroni => '1 1/2 cups', water => '6 cups', salt => '1 pinch', cheese_like_substance => '1 pouch' ); open BOOK, "<" , "Cryptonomicon" or carp "Where's my friggin' book?! $ +!\n"; my @pot = ($ingredient{'water'}, $ingredient{'salt'}); for my $water_temperature (75..212) { read BOOK, $pleasure, 2048 or die "What else has Neal Stephenson w +ritten?"; } push @pot, $ingredient{'macaroni'}; STIR_MACARONI: { for my $minutes (7..10) { read BOOK, $pleasure, 2048 or die "I need another book!"; last STIR_MACARONI if ($ingredient{'macaroni'} eq 'glue'); } } splice @pot, $#pot/2, 0, $ingredient{'butter'}; my $pot = join '', @pot; $pot .= $ingredient{'milk'}; STIR_MACARONI_AGAIN: { my @lunch = split //, $pot; for (0..10) { splice @lunch, rand($#lunch), 0, $ingredient{'cheese_like_subs +tance'}; } $lunch = join '', @lunch; } if ($I eq eat($lunch)) { read BOOK, $pleasure, 2048 or carp "I hate mac and cheese. It's just something to do whi +le reading."; } sub eat { my $food = shift; if (BOOK) { for (0..length($food)) { $food = substr $food, 0, (length($food) - 1); } } else { print "$food must be good if you ain't reading!\n"; } }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: poem [id://31023]
Approved by root
help
Chatterbox?
[holli]: hessenrap...
[holli]: love it :)
[Corion]: acapella hessian rap, but they also do melodic stuff, like Shout (Tears for Fears)
[karlgoethebier]: Rap rhymes to crap. Ouch!

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2017-11-18 19:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (277 votes). Check out past polls.

    Notices?