Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Fun Stuff

by vroom (His Eminence)
on May 25, 2000 at 20:42 UTC ( #14805=sourcecodesection: print w/replies, xml ) Need Help??
Random maze generator
on May 19, 2009 at 11:05 UTC
by ambrus

This is the rewrite of an old random maze generator I wrote in C. It uses the same method for generating the maze, but the interface is different: the old one let you traverse the maze while seeing only your immediate environment, whereas this one only prints the maze as an ascii art (view in a fixed font).

The @ marks the starting position and > is the goal.

"Divide" challenge app
on Mar 12, 2009 at 07:46 UTC
by grizzley

Application visualizing "Divide" challenge. Run it without params - you can play the board loaded from __DATA__ section. Pass dimension (integer) as first param - program will generate random board for you, which you can paste into __DATA__ section.

The goal is to place all connections marked green between left and right side nodes, and red connections between nodes on one side.

TODO: canvas size scaling
refresh canvas on resize
draw initial connections (right now you must click 'Swap' to see initial board)
try to connect lines to nodes - this could allow automatic redrawing and resizing
more colors for connections
small random offsets to coordinates of buttons to avoid labels' overlapping

Greyhawk Deity Tool
on Mar 10, 2009 at 01:09 UTC
by bellaire
An example of things I do when bored at work. Not a terribly good example of much else. We use the names of Greyhawk deities for our internal projects, and scanning the Wikipedia page to find them was getting old. So, uh, this thing grabs the page markup using LWP::UserAgent, does some simple parsing, and internalizes the result for easy searches.

Update: As requested, made some minor adjustments to the usage description which should improve its clarity.
How to call Assembly language routines from Perl
on Nov 26, 2008 at 00:17 UTC
by bitshiftleft
This article shows how to write and call assembly language routines from Perl. I am using ActiveStates version of Perl on Win32. I used Win32::API, but other External Call modules can be used. Unlike the VB trick of using a callback from an API call to execute asm code, the method here is more direct. If you want to explore Win32 memory with Perl here is one way to do it. Also it is another way to learn assembly langauge. This code could be made more robust with Windows memory access API: VirtualQuery(), VirtualProtect(),IsBadReadPtr(), rtlMoveMemory(), ... and so forth. Look after __END__ in code below to see my output of the program
Image and Text Watermarked Letters
on Nov 25, 2008 at 17:49 UTC
by zentara
Just a simple script to show how to add semi-transparent images and text to an image, or in this case a blank US letter sized paper.... ready to run off reams of copies. This particular example is for Perl. The Programming Republic of Perl stamp is base64encoded into the script.
SmiffyCalc (SC)
on Sep 16, 2008 at 23:11 UTC
by smiffy
SmiffyCalc was the result of my not being able to get on with any of the regular command-line calculators that are available. Essentially, it just feeds the user input to eval() and returns the result. To this, I have added variables, the ability to preserve state between sessions (via a tied hash) and some little features that tickle my rather challenged sense of humour.
Tk::Zinc based geometry puzzles
on Apr 21, 2008 at 17:06 UTC
by thundergnat

One of my friends teaches math to 7th-8th graders and came up with a little puzzle game to help demonstrate elementary geometry (coordinate systems, transform/translation of shapes). It consists a series of puzzles cut out of cardboard that the students assemble to form a perfect square.

He was showing it to me and mentioned that it was getting unwieldy to keep all the individual puzzles sorted out and in their proper envelopes. A lightbulb went on and I whipped up this script for him.

This is a simple puzzle game. Each puzzle has 2 or more pieces that you can drag and/or rotate to fit together to form a perfect square. Every vertex of each piece falls exactly on a 4 X 4 unit square grid, so each piece is described by its whole number verticies on a 0 .. 4 by 0 .. 4 cartesion grid.

Many of the puzzles are simple, some are tricky, all have at least one solution.

Works under Windows and Linux (and probably others but haven't tested).

Update: Added smoothing suggested by zentara

D&D Initiative Tracker
on Apr 19, 2008 at 04:34 UTC
by pobocks
A program in Perl/Tk to enter and display a list of character names, sorted by initiative number and dexterity score. If you don't understand that sentence, you won't find the program interesting.
Linux 3D Space Navigator control
on Apr 08, 2008 at 22:25 UTC
by shotgunefx
Rudimentary code for using a 3Dconnexion SpaceNavigator™ under Linux using the /dev/input/eventN interface. Currently what I'm using to control Auto-DAC, my Automotive media player. (video of the navigator in use, here )
quick and dirty cryptogram puzzle
on Jan 01, 2008 at 09:37 UTC
by Snarius
Here's a little game that I made today. It finds a fortune using the fortune command, scrambles the letters using a substitution cipher, and has you guess what each letter represents.

This requires fortune and gtk2-perl

This can be challenging. If you have trouble, either increase the mininum fortune size or use the Jack Bauer fortune file.

It can also be very easy. A lot of fortunes have unique patterns that are easy to spot.

I made this for my grandfather, but I don't know if I'll have a chance to set it up on his computer.
Shuttle Puzzle solver
on Sep 25, 2007 at 02:10 UTC
by jima
I was perusing back issues of Creative Computing at the library and ran across some problem sets from computer programming contests that were held in the late 1970s and early 1980s. Being a past participant and winner of programming contests, I checked out the problem sets, just to see what kids were expected to solve 20+ years ago. One of the puzzles that they had to solve was the Shuttle Puzzle, in which you have to switch two groups of marbles on a board. When the problem was presented in the contest, it came with a big hint to help the kids to figure out how to solve the puzzle. This Perl Tk demo program is a result of my work on that puzzle.
phoon - show the phase of the moon
on Jul 25, 2007 at 17:01 UTC
by jima
A Perl translation of Jef Poskanzer's phoon program.
word twist
on Jun 18, 2007 at 06:48 UTC
by ysth
Based on a popular word game with a similar name on an unnamed ActiveX based site. Given 6 letters, guess all words that can be made from those six letters. Enter "-show" to show all unguessed words for one round, "-new" to start with a new set of letters.

The code was hacked together quite sloppily, but it does what I want it to do.

Random wallpaper harvester
on Mar 18, 2007 at 11:34 UTC
by Snarius
This script (ab)uses the google image search to find an image of adequate proportions from a random word from your computers dictionary file, and attempts to download it and set it as your desktop wallpaper. If you supply words arguments, then this script will use them as the basis of your search.

This is originally based on Hossman's thing that does the same thing, which uses code that was part of Webcollage. (I couldn't find it now.)

Whatever. A well oiled machine needs many ingredients.

Requires gnome2 to set the background. Could use help setting it for other systems.

EDIT:replacing dos-style newlines. how did those get there?

EDIT 2: try flickr mode now.

Mastermind Game in Perl/Tk
on Jan 23, 2007 at 15:50 UTC
by Anonymous Monk
A version in perl/tk of the game known as Master Mind, it's not an example of good programming, sure, but it works :)
Yet Another Sudoku Solver
on Aug 26, 2006 at 18:31 UTC
by SubStack
This script solves any sudoku puzzle that can be solved (as far as I can tell). I started out with a simpler version that only solved easy puzzles and then retro-fitted it to solve the harder ones where the player must follow out potentially useless trails.
A complete perl roguelike
on Jul 15, 2006 at 01:28 UTC
by dabreegster
My main project for the past year has been a Perl roguelike engine. I finally produced the first game with the engine, and I'd like to hear feedback on the game and, if anybody's brave, the code. The game consists of quite a few modules, data files, and such, so I've packaged it together: Who knows? You might enjoy it!
Strangely addictive Tk::Zinc based game
on May 05, 2006 at 02:35 UTC
by thundergnat

I've been puttering around with the Tk::Zinc package, trying to get a handle on it and decided to do a little simulation of a ball in a gravity field. I set up the mouse pointer to be a "point source anti-gravity field". It is strangely addictive to try to keep the ball aloft by repelling it with the mouse cursor.

To make it interesting, the "anti-gravity" field strength decreases over time, so it becomes more and more difficult to keep the ball up. 10 seconds is simple, 20 easy, 30 hard, 40 difficult and 50 plus nearly impossible. The tested limit, (when the "antigravity is too weak to support the ball,) is at 75 seconds, but it would take someone with the reflexes of a fast twitch FPS god to get much over 60 seconds. My personal best is 42 seconds.

Requires Tk::Zinc.

Update: Rewrote it a bit to do less calulations inside the loop. Added automatic update speed detection to set the update speed to a value appropriate for your system. Override automatic speed detection by passing in a delay value in milliseconds at the command line. (20 to 80 ms range recommended.)

Calculate Age, days to next and days from last for a given birthday
on Apr 28, 2006 at 20:03 UTC
by ruzam
This is a little function to calculate a person's age, the number of days to their next birthday and the number of days from their last birthday.

If the birthdate is today, then the number of days to and from the last birthday = 0.

I can't say for certain that it's accurate for all situations (leap years and what not), but it's quite simple and doesn't rely on any additonal modules other than Time::Local which should be standard.

- changed the name to 'birth_date_age_today' so there's no confusion as to it's purpose.
- Removed current day and month as these are not used.
- Used timelocal_nocheck to account for birthdates on Feb 29 - Added condition to leap year check so script continues to operate in the year 2100
- Added more comments (so people don't get the wrong idea about leap years). - fixed missing brackets on leap year test - added test code to check results
secret santa
on Jan 02, 2006 at 17:50 UTC
by smokemachine
secret santa drawing
AM Radio Station Finder
on Dec 21, 2005 at 22:03 UTC
by davebaker
This small script (with a large appended DATA section) was written in 2005 for my 11-year-old son, who enjoys listening to AM radio late at night in bed. He tries to find "DX" stations, meaning long-distance stations that are capable of being received at night due to the "skip" off of the ionosphere. This program shows which stations in the U.S. and Canada are broadcasting on a given frequency, and conversely shows which frequency and how much power a given station uses. About 5 megs in size due to the database from the FCC.
Sudoku Generator
on Dec 13, 2005 at 03:27 UTC
by turo
This program generates a random Sudoku table, and prints it out to the screen so you can copy it to the paper and try to solve it. It has different levels of difficulty, and is, in general terms, a funny program (or should i call it 'a funny hack'?).
Maybe future versions (if any) will have sudoku generator, sudoku solver, and a nice sudoky curses game? hahaha ... I invite perlmonks users to play with it and, of course, to modify it ;)
Happy Sudoking!

PS: The difficulty implementation is no so well balanced :'( ... some times it generates a multiple solutions sudokus ... this is really annoying!
SuDoTKu - version 2
on Aug 09, 2005 at 00:00 UTC
by polettix
If you liked SuDoTKu, you'll enjoy this! It's a substantial rewrite of the game interface, which is pretty good and usable now IMHO (you can see a snapshot here). The biggest defect is that it has quite a slow initialisation, due to the fact that there are many widgets.

There's a bare-bones help about the controls. Anyway, no more keyboard, but only mouse interaction; moreover, I eliminated right-buttons for Mac users (fixing a cell is now done with double-click on the choice).

If anyone knows how I can speed-up the initialisation process... please let me know!!!

on Jul 25, 2005 at 02:30 UTC
by polettix
Enhanced version SuDoTKu - version 2

A small Tk application that will help you playing SuDoKu.

You can display up to 5 characters in any cell, to register possible values, and you can freeze a cell by right-clicking. Of course, you can only fix cells containing one digit.

During the game, you can check the board status with the "Check" button. This will check only fixed cells, so your guesses will not interphere.

If you're going to make guesses, you can "Push" the current status over a stack, and you can undo to that status with the "Pop" button. Yes, this is a macro undo.

If you provide a filename on the command line, the application will try to load it upon startup. You can click "Save" to save the current status, of course.

Exit will not ask you for confirmation, so "Save" before :)

How I use it: put the initial setup and freeze the cells, "Push" and start putting elements. When an element fits directly, I freeze it immediately, otherwise I put the different choiches inside the entry. From time to time I hit "Check" just to be sure I'm on the correct track.

The file format is simple. Cells are saved one element per file line, by row. Each element has two parts: the value inside the cell, and the status, which can be "starter", for fixed cells that form the starter grid, "fixed" and "normal", with obvious meaning (ok, the first is for fixed cells, the second for those cells you can edit).

Update: modified the readonly into disabled as per jbrugger's suggestion. The look-and-feel should be the same anyway - a fixed entry is blue and bold.

Update: removed silly bug, changed relief for fixed cells, translated check messages into english.

Update: removed bug with push/pop. Added support for "starter". Added file format.

Number Guess
on Jul 15, 2005 at 00:34 UTC
by cryptoquip
This is just a simple little guess-the-number game, and basically my first script after "Hello world." ;-) It works, but I'm sure it could be smoother. Comments welcome.
Smiley (emoticon) encoding scheme
on Jul 01, 2005 at 01:59 UTC
by polettix
A simple encoding scheme using four smileys. Example:
user@host> perl -e 'do ""; print encode("ciao")' :D :( :) :/ :/ :) :) :/ :/ :( :) :/ :D :D :) :/ user@host> user@host> perl -e 'do ""; print decode(":D :( :) :/ :/ :) :) + :/ :/ :( :) :/ :D :D :) :/"), $/' ciao
Pikture - yet another ascii art drawing program
on Jun 10, 2005 at 18:48 UTC
by X-3mE
It's been a while since my last post. Anyway, here comes a nice ascii-art drawing program, but it *works only under xterm* because it uses xterm's DEC private mode attribs. It uses Term:: and escape sequences for the "gui".
Enjoy and let me know if you like it :)
All work and no play makes Jack a dull boy
on Jun 07, 2005 at 16:55 UTC
by kaif

You may have seen Jamie Zawinski's program jack.c before. Since I need to write a description, I'll spoil the fun: running man bash through his program prints something like

dull boy. All work and no play makes Jack a dull boy. All work and + no play makes Jack a dull boy. All work and no play makes Jack a dull +boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. +All work and no play makes Jack a dull boy. All work and no p +lay makes Jack a dull boy. All work and no play makes Ja +ck a dull boy. All work and no play makes Jack a dull boy +.

However, his program clearly needed a rewrite (and upgrade) in Perl. So, here's my version, complete with command-line options -c for whenever you feel like running code through and -j to change Jack to JAPH. Other than the above options, my main improvement is spacing and alignment (to make it more like the original output of man). The same section of man bash now looks like

dull boy. All work and no play makes Jack a dull boy. All work and + no play makes Jack a dull boy. All work and no play makes Jack a d +ull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. +All work and no play makes Jack a dull boy. All work and + no play makes Jack a dull boy. All work and no play makes J +ack a dull boy. All work and no play makes Jack a dull boy +.

Go ahead, try it out! Run -c -j today!

Wizard v1.2
on May 16, 2005 at 15:03 UTC
by void_Anthony()
new monsters: demon, troll, orc, bats (varying in difficulty while some giving you more gold than others.) Toad spell replaced with fireball (does damage depending on wizard level * 2 instead of instantly killing enemies. You will always have a 50/50 chance of successfully casting it.) Cleaner code :). Run option is available during combat. Health goes up by 20 instead of 30 with 10 gold. Damage from enemies is random (Within a certain range, the higher the range with the harder the monsters.) I forget the rest :). Note: Initially, work on raising your damage level. The game will be much harder if you don't! Credit for modification ideas and code snippets goes to:wazoox, CountZero, Roy Johnson, deibyz, cbrandtfuffalo, holli,and eric256.
on May 05, 2005 at 23:42 UTC
by void_Anthony()
Wizardv1.0 with some minor modifications to the 'shop' sub, a new level, a new enemy, and a little bit of small error catching. -credit for Wizard v1.0 goes to 'legolas'
ASCII analog clock
on Mar 18, 2005 at 18:33 UTC
by polettix
Something that any terminal should not miss in their spare time...

A quite simple analog clock in ASCII. I made it for fun in little time, so there's no optimisation (for example, I know better algos to write a line, but I was too lazy to get to my copy of Foley/Van Dam...).

You can set the clock size (x and y) on the command line; defaults to 45 x 23.

Updated: added screen clearing using one advice from here and fairer input usage. I tested clearing in xterm and cygwin window and it seems to work well.

SuDoKu solver
on Dec 17, 2004 at 13:18 UTC
by Brovnik
# VERSION 2 changes :
# - Now copes with more difficult puzzles
# - Lots more documentation
# - Clearer reporting
# Solver for SuDoKu puzzles.
# See enclosed Pod docs for more details.
# Uses Quantum::Superpositions to store partially known states.
# usage : ./solver < p1
# Where p1 is a SuDoKu puzzle.
# Example : (strip comment and leading whitespace)
#   ..21.64..
#   ..93875..
#   7...2...8
#   ..1...7..
#   .9..3..6.
#   ..5...8..
#   8...6...5
#   ..34786..
#   ..49.13..
# Rules are simple :
# Each column, row and 3*3 square contains the numbers 1..9
# once each.
# In the example above, some numbers are provided to help you.
# See also
Perl Missile Defense with Radar
on Dec 02, 2004 at 20:36 UTC
by zentara
Building upon the successful and profitable Perl Missile Defense Shield , I have added a Mach 1 "fully automated radar fire control", which can be used as a "pause" button. :-)

UPDATE1: Added "sound on/off".

UPDATE2: Fixed "bug" where shells didn't destroy themselves when hitting target.

Perl Missile Defense Shield
on Dec 01, 2004 at 17:45 UTC
by zentara
My contribution to National Defense. :-) Up and Down Arrows adjust firing power at battery expense. Left and Right keys rotate turret. Spacebar fires.

It would have been easier with Tk::Zinc(which supports rotations); but I kludged a way to rotate with the plain canvas.

If one warhead hits the ground, it's over.

Of course, fully automatic versions are available with a DOD contract. bwa ha ha :-)

plong - a pong clone with SWF::File
on Nov 23, 2004 at 19:16 UTC
by teabag creates a Flash (SWF) file of the classic pong using the SWF::File module. You can dump compiled flash-files with this module and change variables, colors or even symbols and animations in the script.

I had to cut down the size of the script for it to be posted here (64k max) so be sure to feed it to perltidy if you don't like the formatting.

I know it's a whole lot of code for such a simple game, but I didn't see any SWF::File code here and it deserves some attention. Next time I'll show an example of Ming Perl

update:Working output example for belg4mit.

Pentris - a Tetris clone
on Aug 23, 2004 at 11:45 UTC
by Crian is a rewritten Tetris clone I wrote 1993 in Fortran 77

I used Perl/Tk this time, the Version 0.0.2 I show in here is the work of one weekend.

A webpage for Pentris can be found here: (it is a german page)

I put the code under the licenses of perl itself, see pod.

The comments and variables in my program are in english, only very few comments are in german, I will translate them later.

UPDATE: Version 0.0.3 is online, that one has a parameter 'nogrid' that disables the grid.

UPDATE: Version 0.0.4 is online, now you can switch the grid on/off via F3 (and via Menu) even while you are playing. a poetry scraper
on Jul 15, 2004 at 19:42 UTC
by eweaverp
Grabs the complete works of any poet on and sticks them in a text file (alphabatized). Includes _PAGEBREAK_ markers for your favorite word processor's find/replace command.

Quick and dirty.

Invoke with  ./ NumberOfPoetAccordingToPlagiaristCom OutputFilePrefix

i.e.: ./ 91 jeffers_robinson
Regexp of Regexp
on Jun 02, 2004 at 17:51 UTC
by mtve

Regexp that matches regexes. The only difficulty is with /x modifier, so comments in following code intentionally made regexp-valid.

Tic-Tac-Toe bot
on Jun 01, 2004 at 22:50 UTC
by delirium
A command-line Tic-Tac-Toe bot. See here for my comments on the bot's design.
Lottery Numbers
on May 03, 2004 at 00:59 UTC
by OverlordQ
Takes the results of past lottery drawings and feeds it into a weighted random number generator to guess future results. Horribly inefficient I suspect.
on Apr 07, 2004 at 05:44 UTC
by mawe
You like Action-Games?
Forget Doom, Quake, Solitaire and Mahjongg! Here comes CamelTrouble ;-)

As you will see, my perl skills are.. let's not talk about it :-/ I think there are some bugs (one I know occurs when you collect the monks). If you have the time, please give me some advice how to improve the code, I'd love to learn from your comments :-)
Have Fun!

Update:Fixed winning detection as PodMaster suggested
Update:Fixed some typos (thank you Albannach)
Update:Fixed monk-collection-bug with help from Vautrin and hossman

PONG with TkZinc
on Nov 15, 2003 at 17:14 UTC
by zentara
This is a PONG game made with the TkZinc module. TkZinc is a "canvas" with excellent 2d translations and rotation, and includes "groups". A PONG screenshot. Also, I have been documenting my "learning process with TkZinc, and have it in a beginner's tutorial at TkZinc Beginners Tutorial.
Spanglish Translator
on Nov 09, 2003 at 11:51 UTC
by OverlordQ
A Fun script that was coded when we were taking Spanish Classes. What this script does is translate a selection of text, or an URL into Spanglish, which is a hybrid of English and Spanish.

A Working example can be found here
on Sep 17, 2003 at 19:47 UTC
by Anonymous Monk
A simple puzzle game.
Babelfish Text Mangler
on Sep 16, 2003 at 01:43 UTC
by #include

A fun little toy that mangles text using Alta Vista's Babelfish Service by repeatedly translating the text. It uses WWW::Babelfish (and thusly IO::String) to do the translation, and is extremely configurable. As an example, if the script is run with

$ perl -i file.txt -o mangle.txt -m French,Spanish,German

It will translate file.txt first into French, then into English, then into Spanish, then into English, then into German, and then back into English. Then, it saves the "mangled" text to mangle.txt.

You can see some example output posted up on my weblog, "The Steb-by-Step Guide To World Domination".

perl options

Options marked with a * are required
-i <filename> - Loads a file to mangle*
-o <filename> - File to write mangled text to*
-s <language> - Singlepass mode, with the specified language
-b <language> - Base language. English by default.
-m <language>,... - Multipass mode. Any number of languages seperated by commas. Default is -m French,Spanish
-t <language> - Translates one language to another

UPDATED: I added a "simple" translation mode, allowing people to use the script to actually translate text documents.
minimal game of life
on Sep 14, 2003 at 00:59 UTC
by mayaTheCat
a minimalist implementation of the "Game of Life".

the reason why I have coded such a stuff is that
I like minimal code (although this code is not so minimal - I have problems with the function n())
and this is just a practice ...

in this code,

  • the grid is defined as a torus,
  • the script outputs to terminal,
  • thus, it prints 24 - the height of the grid.
  • therefore, it is better to define widths and heights that make the grid lay inside a terminal.
perl/cgi Boggle
on Aug 15, 2003 at 21:24 UTC
by ajdelore

Lately I've been obsessed with playing boggle. So, why not whip up a web-based boggle game, I thought? A couple of days and a CPAN module later, this code is the result.

You can check out a live demo on my website.

Uses Games::Boggle::Board (which I wrote), Games::Boggle to check words, and HTML::Template for output.

Next on my list is to develop code to find all possible words in a given board.

Sieve of Eratosthenes with closures
on Jul 20, 2003 at 22:26 UTC
by thinker
A Sieve of Eratosthenes implemented with closures.
I was looking over an old Java project for Uni where I had implemented a Sieve as Objects connected by pipelines.
It occurred to me closures could do a similar job far more concisely. Here was my effort. I hope this is the correct section to post in. I found it fun, anyway. :-)
Trans-OS PONG simulator!
on Jul 18, 2003 at 05:21 UTC
by wombat
So I had bought the Perl/TK book recently, and I decided to begin to hone my skills at making GUI apps. When I came upon the section on how to make decorationless windows, I was struck by a bolt of GENIUS (madness). I already had x2vnc connecting the desktops of my Linux and Windows computers. Why not build a dumb little program that makes it look like the two machines are playing PONG!?

All you need to run this, is ideally two computers side by side. There are three variables inside the program, after the XPM bitmaps, that need to be set properly. This is because I was _lazy_ and didn't feel like adding argument functionality. The variables are:

$left: The computer on the left must have this set to zero. The computer on the right must have this set to one. (Yes, I know it sounds backwards, but left comes before right, and zero comes before one. If it bugs you do a s/\$left/\$right/g.)

$multiplier: My linux box runs at a different resolution than my windows box, due entirely to differing monitors etc. One machine should have a multiplier set to 1.0 (the default) The other should have it set to the ratio of the two resolution heights. My case is 1.36. If both are set to 1.0, then undefined hilarity will ensue when the larger monitor passes a value out of range of the smaller monitor. {Actually, the ball will just get lost, eventually bounce off the rear wall, and then reemerge on the larger monitor})

$player: This needs to be set to the IP address of the opposing computer. That's it.

Message passing is accomplished by a four byte UDP packet being sent on port 9628 each time the ball hits the center divide. Because of the size of the packet, this necessarily will not work properly on monitors with a resolution greater than 9999 pixels in height.

Any other questions or comments, write away!

~W (Yeah, I'm back!)
Neopets Times
on Jun 05, 2003 at 07:41 UTC
by sulfericacid
I am an avid player of and I know a lot of people keep asking what events happen at what times so I designed a script to count down to key events that happen throughout the course of the day.

The script tracks three events (snowager, jobs and the new day). I doubt many of you would have much interest in this script but who knows, maybe some of you play on that site too.

From this script I learned: Calculate time between times and operations.

Problems: I know there is a lot of repetitive code but it's the best I could do.

Gaim Magic 8 Ball
on Jun 03, 2003 at 04:10 UTC
by #include
This script is a perl plugin for Gaim. To install it, just copy the script into your "plugins" directory, restart Gaim if it is already running, and then turn it on in the "Preferences" menu. This script turns your Gaim client into a Magic 8 Ball. If anyone sends you an instant message containing "!8ball" followed by a question, the script will select a "random" answer, and send it to the requesting client. This won't interrupt your regular IM traffic, and is all done in the background.

Edit: Updated and fixed a bug. Now all possible 8 ball messages are used. Thanks Juerd.
PerlMessy: Perltidy's little tattletaling sister
on Jun 03, 2003 at 03:08 UTC
by jacques
This small program rates a file's adherence to perltidy guidelines. You can easily modify it to meet your requirements. It was developed on a win32 platform with the standalone perltidy script.
Convert Image to Text
on Jun 02, 2003 at 16:56 UTC
by fockjef
This is an old project that i just rewrote in perl. It reads any type of image that ImageMagick supports, converts it to black&white, and then converts it into text. This requires the ImageMagick package. Also, it really helps to do some editing to the pictures to improve the results. Some examples of the output can be found at Peace jef
IRC Dice Roller
on May 12, 2003 at 20:47 UTC
by Flame

This program is an IRC dice roller that connects to an IRC server and joins a room specified on the command line. Once connected, the program waits for someone to say a slightly modified form of the D&D dice format: "~xdy+b". Here, x is the number of numbers to generate, y is the max number, eg: 1..y and b is an optional number to add to the total. When it recieves this, it generates the numbers and spits out a list of each number it generated, followed by their sum.

It was originally written for and tested with the following, but barring any significant changes in interface, it should work cross-platform and with any newer versions of the modules:

Net::IRC        0.73
Pod::Usage      1.14
Getopt::Long    2.32
strict          1.02
Perl            5.008
OS              MSWin32

Further documentation can be found at the end of the program as POD.

on May 05, 2003 at 01:41 UTC
by tinypig
This was my first adventure in creating a Perl/Tk game. I think I stuck with it long enough that it is both stable and somewhat fun. Although it's nothing I would spend a quarter on in an arcade, I think it makes for an interesting diversion. The code won't work without the accompanying files, so if you want to play the game, get the compressed tar or zip file. Feel free to comment/criticize, etc.
Wasting time with Parse::RecDescent and POE
on Mar 21, 2003 at 12:54 UTC
by rob_au
After having had what has seemed to be an eternally long week at work this last week, I sought to put something fun together to kill some time. Given that much of my work of this week has been split between data munging with Parse::RecDescent and application development with POE, I thought, "Why not combine the two?".

The result is the following code which uses the Abbott and Costello "Who's on First?" grammar written by Damian Conway for his article "the man(1) of Descent" in Issue 12 of The Perl Journal in a POE based "chatter" application.

This script, when called without any arguments, takes on the role of Bud Abbott and establishes a TCP server, on port 12477, for communication. When called with a hostname as a single argument, this script connects to the server component on that host and plays the complementary role of Lou Costello.

[bored] senseless amination
on Mar 18, 2003 at 11:00 UTC
by photon
this is just a senseless ascii animation :)
Guess A Number
on Mar 17, 2003 at 07:21 UTC
by sulfericacid
Generates a random (or semi-random) number based on user's inputted $max. Object of game is to guess the number before your chances run out (default set at 5). Games completed, won and lost are stored into a database and presented to the user after each game.

# Small bug fixed: Thanks Enlil!
# Indents fixed: PerlTidy saved the day

From this script I learned: naked blocks (which are a total life saver), the easier way to increment database variables and furthered my experience with regex (as scary as that is).
We're Going on a Bear Hunt
on Jan 18, 2003 at 19:28 UTC
by Mr. Muskrat

An age old children's story/song that has been told many times in many, different ways. I have been looking for as many different versions as possible but so far, I have only found this one and two others (one and two)

And a book by the same name by Michael Rosen but I haven't seen it in stores yet.

I wrote it because my children absolutely love this story and I am getting very tired of reading it three or four times a day! I am going to rewrite it so that it speaks the words of the story out loud so that I don't have too. :) Once is enough for me!

If it looks a bit cryptic or obfuscated in places, that is because I was going to write it as an obfuscation.

Nibbles Tournament!
on Oct 24, 2002 at 18:37 UTC
by twerq
You've played it on your Nokia handset, you've played it in QBasic 4.5, you've seen Tron. Now experience it in full ASCII glory! Head-to-head action via UNIX Domain sockets was the inspiration behind Nibbles Tournament!
'96 ACM Problem A
on Oct 06, 2002 at 20:15 UTC
by jjdraco
I've searched long and hard for programming problems to try so that i could practice writing programs and improve my skills. i cam a cross ACM which hold an annual programming contest for College students. Even though I'm probably not elegable to enter the compatition, I did find that they keep an archive of all they're past problems for they're contest, so theres nothing stopping me from writing my on solution to the problem for the benefit of bettering myself.

well this is my solution to Problem A in the 1996 contest. You can go and read the full problem, but basicly given a standard deck of 52 cards it plays a solitaire card game called 10-20-30 and prints out the results: Win, Loss, Draw and the number of cards dealt in that game.
I have a few conserns with my solution however. I think theres still some bugs in it and I can't find them, but I think its in the subroutine _gameOver(), or _draw().
given the test cases on the website my results should print out:
Win: 66
Loss: 82
Draw: 73
but the results I'm getting are:
Win: 66
loss: 118
Draw: 75
As of yet I haven't found out why my results don't match theres. I'm tempted to sit down and play the game with a deck of cards myself and see if I still get the same results.
Also I have a question on proper programming.
I have subroutines that I don't expect to get called outside the module. I name all these subroutines with a '_' underscore in front of their names, I also still pass $self to them because they need that information. Is the way I did it poor style? How should I have done it?
I would also like to appologies for the really long comment in the play() subroutine, but I thought someone might not understand my line of thinking.
And the last consern I have with this program, or the last one I can think of is...@history, which holds the previous states of the game. I use this to test for draw since a draw happens when a state repeats itself. I defined it outside of _gameOver() and _draw() but in a block so that both functions could see it and it would hold its contents through multipule calls to the two functions. Should I have down this some other way?

Thanks for any feedback
Wizard v1.0
on Sep 22, 2002 at 16:19 UTC
by legolas
This is the first code I have done in a while. I wanted to make a game that would be easy to modify so people could change the game to fit their liking. I want to change it so you can be other things besides wizards and I want to add more spells monsters and areas. I think the code seems sluggish so if someone could help please respond, thank you. Tell me what you think and have fun with it.
Perl Card Trick
on Sep 15, 2002 at 02:13 UTC
by Lysander
This is a card trick that I remembered doing when I was a kid. The idea behind it is pretty simple, but it may stump some of you for a moment. ;) Cheers.
on Sep 13, 2002 at 18:49 UTC
by Lysander
This script is a Perl rendition of the game "Hangman". You can play it it two modes: Single Player or Challenge. Challenge mode allows two people to play. The challenger enters in a word/phrase and a clue. The challengee then tries to guess it. Also, any phrases/words entered in challenge mode will be stored in a DBM file for use in Single Player mode. Enjoy.
AI Animals
on Sep 08, 2002 at 06:27 UTC
by Limbic~Region
Program follows a logic tree to guess an animal that you are thinking of. The more it plays - the better it gets, hence the AI reference. It is based off a game I saw on an Apple something or other way back in gradeschool. Of course, I never saw the source - so this is my guess of how it is done.
on Aug 31, 2002 at 20:29 UTC
by Gordy
A simple maths quiz, answer as many as possible before the time is up. It works but as I am very new to perl I expect there are many things which I could have done much better, constructive critism is very welcome.
Someone get the coffee
on Aug 21, 2002 at 03:54 UTC
by hagus
A self contained CGI script to manage your daily coffee runs. Everyone adds their name + email to the web page, and when it reaches a certain amount of entries (3 by default), the coffee order list is then mailed to everyone. It's up to you to decide who actually goes to get them though ;)

Note: in practise, name usually ends up being 'hagus - flat white', combining name and coffee type.

Blob Maker
on Aug 21, 2002 at 03:17 UTC
by legolas
This is a simple program that draws squares out of asterikses. I did it basically to learn about strings and loops. Nothing spectacular, but a fun program nonetheless.
99 bottles of beer on the Wall
on Aug 21, 2002 at 02:31 UTC
by legolas
This was my first program. I did it after about an hour or two of reading Learning Perl. I relize there are other programs that do the same thing more efficiently, but this is my first program and I have much to learn. interface w/ Win32::Clipboard support
on Aug 12, 2002 at 05:43 UTC
by thealienz1

This script requires use of the Win32::Clipboard Module.

This is the same as my code, but has a built in interface for the Win32::Clipboard module. That way if you want to copy something into the clipboard, instead of typing it out again, the script will automatically translate whatever is in the clipboard, and write it over with the translation. I have it setup so, I can just use some shortcuts to do english<->lingo. interface
on Aug 12, 2002 at 05:21 UTC
by thealienz1

I was crawling the internet one day looking for translators for SMS text messaging. You so, I could be kewl, and confuse my friends with a language even I didn't understand. And so I found It offers translation for english<->SMS lingo.

I wz crawling d internet 1 dA L%kN 4 transl8rz 4 SMS txt msgN. U so, I c%d b kewl, & Confuz my fRnds w a language even I didn't undRstNd. & so I found it offers transl8n 4 english<->SMS lingo.

Skrabbel 2
on Aug 08, 2002 at 21:47 UTC
by Fideist11
This is the fruition of my labors to build a program to find all the best moves in a scrabble game! Right now all the algorithms remain in Perl so, depending on your dictionary size and the number of moves on the board, search time can vary from 30seconds to 7minutes. So once you click "Find" remember to be patient. A pop up window saying "Search complete" will appear when it is done. I plan on porting some of the more time consuming routines to Inline::C to speed things up greatly. You can get all the files for this program, including a windows executable built with perl2exe, a dictionary massaged to include only useful scrabble words, and a sample board file at:
Iterated prisoner's dilemma
on Jul 30, 2002 at 13:58 UTC
by spurperl
A small script showing the Iterated prisoner's dilemma games. Allows to easily add subroutines and thy them against other algorithms.
on Jul 29, 2002 at 14:38 UTC
by Fideist11
This is just an update to the Scrabble program listed above (now with a less copyrighted name?). I've replaced the Win32::MsgBox's with a little TK::Toplevel routine in the hopes of getting the program to run on linux as well as windows. I think it should now but i have no linux box at the moment so i'm not sure...
Scrabble Game
on Jul 25, 2002 at 21:04 UTC
by Fideist11
This program is actually a scrabble-module i wrote with a tk-script wrapped around it. It requires Tk, Tk::FileDialog, and Win32. Win32 is only used for it's MsgBox function in pop-up error messages. Minus these MsgBox's, the program should be cross-platform. You can add moves to the board, load boards from a preset file (with a homemade board-specification syntax) and then resave the board later on in the game. The board also highlights and tracks all premium squares and validates all new moves. An example of a board-file is included at the bottom of the code. The scrabble module maintains a 2-D array of board, a hash of all letter values (like F => 4), and the location and type of all premium squares. I hope to use this foundation, (along with a scrabble dictionary word list) to build the logic to discover the best possible move in every single possible scenario.
Crossword solver - 2 words
on Jul 19, 2002 at 12:41 UTC
by fireartist
Warning:- some may find this offensive ;)

If you have 2 incomplete, interesecting words in a crossword, this will list all possible combinations.
For example, with the 2 words below (marked by '?')
_ _ _ _ _ _ _ _ |_|_|_|_|_|_|_|_| |_|_|_|_|O|F|T|_| |_|C|_|_|_|?|_|_| |_|A|?|T|?|?|?|_| |_|T|_|O|_|?|_|_| |_|_|_|K|_|I|N|_| |_|_|F|E|E|D|_|_| |_|_|_|_|_|_|_|_|
The program will ask you these questions, to which you should give the marked answers.
How any letters does word 1 have? answer:6 What position does it meet word 2 at? answer:5 What is the 1st letter? Hit <RETURN> if you don't know. answer:a What is the 2nd letter? answer: What is the 3rd letter? answer:t What is the 4th letter? answer: What is the 6th letter? answer: How any letters does word 2 have? answer:6 What position does it meet word 1 at? answer:3 What is the 1st letter? Hit <RETURN> if you don't know. answer:f What is the 2nd letter? answer: What is the 3rd letter? answer: What is the 4th letter? answer: What is the 5th letter? answer:i What is the 6th letter? answer:d
You would then be returned the following list.
action florid actors forbid Altair frigid altars forbid alters forbid artery forbid Arturo forbid asters forbid attain frigid attire forbid author florid

update: added the following line
What is the 3rd letter? answer:
where it was missing above.
on Jul 12, 2002 at 17:14 UTC
by dcpve
Finds suitable Scrabble words based on your current tiles, the tiles on the board that are available for word building, and how many of your current tiles you are willing to omit to form a word.
Harvest New Sci-Fi Movie Titles
on Jul 11, 2002 at 06:02 UTC
by hossman
I run a daily email list that provides headlines of Sci-Fi related news. One of the things I include when available is info on new Sci-Fi movies as they show up in the IMDB data feeds. This is the script I cron to get the new movie data. It can be generalized to get info about new movies in any IMDB category.

Since the IMDB data is updated semi-haphazardly, I cron the script extremely frequently, thus I made it 'smart' enough to knot do anything unless it needs to.

My crontab looks something like this...

# This is important for the new-movies script. FTP_PASSIVE=YES # New movies .. several times a night, run the program. # If it's output file allready exists, it won't do anything # # (defaults to 'last friday') 0 0-2,22,23 * * * cd $HOME/new-movies-work; $HOME/bin/new-movies --lazy # New movies ... # Again, not intensive cause it does nothing if the output file has # allready been created by the OTHER call (above) # # "a week ago last friday" 33 0-2,22,23 * * * cd $HOME/new-movies-work; $HOME/bin/new-movies --lazy --datemod "- 1week"
Simple Lottery
on May 21, 2002 at 22:00 UTC
by xgunnerx
Simple lottery program. Will stop running and tell you the outcome when all six numbers are met.
Shut the Box : 12 Number Edition
on Apr 13, 2002 at 01:32 UTC
by munchie
The classic pub game (what do I know about pubs, I'm 13!) Shut the Box, in a twelve number version (the original was 9 numbered). You roll 2 dice, and then you have a choice of putting individual numbers down, or combined numbers (Play the game to get used to it, I can't explain it very well). My dad gave me the suggestion, so that night, I cranked the original script out in less than an hour. There were 2 major bugs that annoyed me to death, so I left it sit for a couple weeks. Today, I came back to it and crushed those bugs flat (pardon my enthusiasm)! Enjoy!

UPDATE 1: Fixed code to change the redo FOO; to process_combos(); I also made it warnings compliant, which I was probably too ignorant to do in the beginning.

Random Background from Net
on Mar 19, 2002 at 03:45 UTC
by hossman
Uses Google's image search to find random background images based on random words, or you can give it some specific words and it will use those.

Edited: Added google disclaimer, and fixed blatent bug with maturity filter.

Graphical Survey Manager
on Feb 24, 2002 at 22:25 UTC
by jerrygarciuh
This script generates polls from a flatfile its admin creates, accepts polling info and uses GD::Graph3d to create .pngs of the results. It has an easy admin backend for adding and deleting new polls. Needed improvements include:
  • Password protection for admin mode which is currently diabled by the limit on requests to POST. There are a lot of ways this can be redressed and I haven't decided which I want yet.
  • A way (probably cookies) to keep folks from repeated voting
  • Improved data structure to make it easy for the delete_survey sub to clean up the .png and .poll files, this won't be hard, I just haven't done it yet.
  • And lastly a way to get GD to print text at a 45º angle. Currently it changes to vertical if the labels get too wide, but this is hard to read. GD::Text::Align has been recommended for this purpose, but not implemented yet.

  • Hope ya dig it!

    See 2.25.02 post in thread for updates. Code below reflects changes posted there. 2.26.02 update: sub referer check updated and it's called moved to the top of the script to prevent saved copies of the forms being manipulated and posted to the script.

on Jan 27, 2002 at 17:52 UTC
by Juerd
This module creates magic squares. A magic square is a square in which all numbers are differet and the sums of all rows, all columns and the two diagonals are equal.

(To be uploaded to CPAN soon)
Doom-Style Status Bar
on Jan 16, 2002 at 23:41 UTC
by Symuc
Reminiscent of the status bar that showed the progress of the startup of the classic game "Doom", this code will print a status bar of variable width with an optional header and/or footer.
Reinventing Dice...
on Dec 08, 2001 at 03:40 UTC
by osfameron
OK I discovered Dice::Dice and RPG::Dice here on Perlmonks but this wheel was such fun to reinvent... this code is more like RPG::Dice, but written in a different way, so I thought it might be worth posting.

update: I quited liked the way I was handling tt clauses, but it was unnecessary. Combined parsing of template into one regex substitution and put the logic into the _roll sub.

Perl/Tk Space Invaders Game/Sprite Class
on Nov 13, 2001 at 00:47 UTC
by clintp
Small Space Invaders game, intended as a demo of a Sprite class for a lecture I give. Feel free to critique, comment, and re-use.
on Sep 25, 2001 at 06:03 UTC
by ChemBoy
A module to provide a simple object-oriented interface to basic information about Major League Baseball teams, with a little overloading sugar for fun. See included POD for detailed information.
Update: added a missing method and the documentation for it, and addressed the symptoms (if not the cause) of one problem pointed out below. 10/02/2001
Monk Ladder
on Sep 15, 2001 at 07:27 UTC
by jryan

There are a lot of monks that play Starcraft (including me), but often times we have difficulty finding people to play with. So, to organize us, I decided to write up a quick ladder. For those of you who don't know what a ladder is (or don't know what a real ladder is, unlike that pathetic bnet one), it is basically a league where one can only advance by playing higher ranked players.

In the gaming community, everyone wants a ladder. However, once a ladder is up, the ladder admin(the guy who wrote it) becomes preoccupied with other things. Without someone to maintain the ladder, it soon dies. Therefore, I wrote a ladder would be easy to setup and maintain by the non-programmer. It is EXTREMELY easy to install; it uses 2 flat text databases (for easy cross-platform support), and was designed to be inserted into pre-existing designs via ssi so the ladder maintainer doesnt have to drudge through a buncha code. All the maintainer has to do is upload the scripts and set permissions, and its ready to go.

I would really like to host this somewhere, if anyone knows somewhere I could do it, it would be really great. It wouldn't eat up much bandwidth or disk space, and I think that it would be one more thing that would enrich our community even more :)

Thanks to jcwren's coolness, is now hosting MonkLadder. Sign up!

on Sep 14, 2001 at 18:53 UTC
by $code or die
A Perl Tk Game.

Clear the grid with the highest score. You can clear blocks when there are two or more identical blocks next to eachother. The score goes up considerably when you get rid of more than a handful of blocks (you'll see what I mean).

See AGamesZone for the inspiration. (Ok, yes, I ripped it off!)

Code is a little rough in places, but it works.
Tested on:
Perl 5.6.1: ActivePerl 629 on Win2000 and Windows Me,
Perl 5.5: on Debian (potato)
Perfect Division
on Sep 09, 2001 at 12:34 UTC
by acid06
I was reading some fun stuff here and couldn't resist when I read this part of the message:
"11. Let's say the program you're writing may possibly try to divide by zero. If this exception occurs, how should your program cope?
b) Redefine the laws of mathematics so that any number divided by zero is equal to 42. Problem solved."

So... here it is. All you have to do is save it and use PerfectDivision;

Note: it doesn't work unless you provide the values on compile time, so you can't do stuff like print $ARGV[0]/0; without getting the Illegal division by zero error.
update: corrected a bug which prevented it from working properly
3D Hidden Text
on Aug 24, 2001 at 05:26 UTC
by bladx
This is really one of my first perl programs (using the module, which by the way, is really cool!) and is also written for use with a CGI as well. What it does, it basically re-creates what those magic eye book pictures kind of look like, except that it is more like the old days when 3d glasses were new. It's easy to change the variables to change what colors (or even add new colors,) to what is there, and although it is very simple, hopefully it's fun for someone ... (other than me. :-)) BTW, there is a working version of this at: here ... if you want to see it.
on Aug 13, 2001 at 20:04 UTC
by idnopheq
horoscope -- see what the stars have in store for YOU!

I'm not terribly happy right now on how I did this (subs, redundent randomness, additional redunacies, etc.), yet it does work. Comments and recommendations are appreciated.

UPDATE 0: this is my first stab at converting lisp ( which I'm not terribly good at ) to perl. But this thing is so much fun, I could not help myself.

UPDATE 1: Thanks to Albannach and his advice on CB, I rewrote this whole thing as a Hash of Arrays, shortening the script considerably. NodeReaper has yet to make an apperance in this. Please, as before, comments are solicited.

on Jul 06, 2001 at 00:44 UTC
by Masem
Allows one to simulate 1D automata with multiple colors using perl. The POD should sufficiently explain the use of the module.

Comments, critiques, and other inputs are gladly accepted!

on Jul 04, 2001 at 05:08 UTC
by dooberwah
Plibbles is ment to be much like the clasic worm(6) game, but written in Perl. You control a worm that moves about the screent trying to eat numbers. Whenever you eat a number you grow as many segments longer as the number you ate. The object of the game is to get the hishest score by eating the most numbers without running into something.


  • Make worm move forward every 0.25 seconds or so.
  • Document the code
  • Clean up the code

    I'm sure that this isn't the only way to do this, (hey, TMTOWTDI after all) and I'm sure the way I thought up isn't the most efficient way, but it's what I could come up with. Any comments/improvments/questions would be very welcome.

  • RPG::Dice
    on Jun 14, 2001 at 22:04 UTC
    by Syrkres
    RPG (Role Playing Game) Dice expression Roller
    See mod doc for expression syntax.
    on Jun 07, 2001 at 02:16 UTC
    by dshahin
    generates two random rpg characters and fights them to death.
    on Jun 06, 2001 at 13:54 UTC
    by davorg

    The idea of writing a module that could be called T::H::C was too good to ignore.

    Don't trust anything this hash tells you :)

    on May 29, 2001 at 05:19 UTC
    by Masem
    Simulates Conway's Game of Life in Perl

    Comments are highly appreciated!
    on May 02, 2001 at 05:35 UTC
    by JSchmitz
    Rips out all the junk and leaves just working code just type "scriptname" tells ya when its done. = )
    on Mar 24, 2001 at 19:34 UTC
    by dmckee
    Creates a PNG image with runes: hopefully going to make it a lot easier to use. Essentially, change the $text line, and it'll create runeout.png, a picture with the runed font. Requires PNG file from (blame geocities for not supporting PNG, M3U...)
    on Feb 24, 2001 at 18:20 UTC
    by dmckee
    Converts an image in pretty much any format (see Image::Magick to ASCII characters to give the illusion of a picture. Works best with small fonts.
    wsradio: MP3 stream downsampling proxy
    on Jan 31, 2001 at 11:32 UTC
    by strredwolf
    An offshoot of my WSproxy program, this one takes requests for a MP3 stream and downsamples it to 24kbps range. Nice for those streams which only come at 56kbps or higher.

    You will need netpipes and LAME for this one. To use once both are compiled in, use "faucet port -io"

    Find Words a la Boggle
    on Feb 10, 2001 at 00:56 UTC
    by chipmunk
    This script finds words in a block of letters, in the manner of the game Boggle from Parker Brothers. A word may be spelled out by joining letters up, down, sideways, and diagonally, in a continuous path. The same instance of a letter may not be used more than once in the same word.

    For example, the word 'chipmunk' can be found in the following letter block:


    Enjoy! Comments and suggestions welcome.

    A simple game AI that learns
    on Jan 14, 2001 at 01:31 UTC
    by Falkkin
    A set of modules that implement a very simple gaming AI. The AI players know nothing about the actual game that is being played; they merely take in a list of valid moves and provide functions to call at the end of a given game. The AI remembers what moves it's made and the results, and learns how to play the game better, even though it doesn't know any of the rules.

    I've tested this code using tic-tac-toe; after about 35,000 runs of the Defensive player vs. the Random player, the Defensive player no longer loses. I ran ~2,000,000 games and it's not lost once. Since this is basically a brute-force AI method, it'll probably be incredibly inefficient for complex games (although I've not tested it with any other games yet.)

    The code is optimized for speed, not readability... it doesn't pass -w because of hash accesses to undefined values in I'm pondering submitting this to CPAN, after cleaning up some stuff and writing the documentation as pod, so any advice or comments would be much appreciated.

    I still have much to try with these modules, such as:
    - Different games (suggestions, anyone?)
    - Will it learn faster if it plays against a better player?
    - I'd also like to write a CGI script that allows the AI to play human opponents online.

    on Jan 11, 2001 at 11:10 UTC
    by strredwolf
    Anything, a mini-clone of Everything(which runs PerlMonks). This is what I get for trying to organize things with WolfSkunks. It is a CGI script, though, and works well with mhttpd. It will auto-setup itself. Just edit $root.

    Update 1-11: Updated to secure it a bit and use CGI::Lite (which I think is a lot less complicated than all of CGI). The square brackets now work.

    Update 1-29: Updated it again so that updates and node editing actually works.

    Solve Word Ladders
    on Jan 10, 2001 at 20:43 UTC
    by chipmunk
    This script solves word ladders. A word ladder is a progression from one word to another, changing exactly one letter per step. Each intermediate step must also be a word. For example; dog cog cot cat.

    An example of use:
    % ladder perl monk 10 perl merl merk mirk mink monk
    "merk"?? Let's find a better solution...
    % ladder perl monk 10 merk perl perk peck pock mock monk
    That works!

    See the POD for more info.

    (Updated to version 1.5; minor POD corrections only.)

    Array Shuffler
    on Jan 09, 2001 at 16:09 UTC
    by zencrypt
    I think too much emphasis is placed on sorting lists. Bubblesort this, and quicksort that, and selection sort something else. But what about random shuffling? I never see any attention given to the opposite of sorting; shuffling! I wrote out some basic code that i think does the trick, but if anyone has any tips on how it can be improved, please let me know. thanks
    99 bottles, 2 lines
    on Nov 28, 2000 at 08:33 UTC
    by chipmunk
    Some time ago, there was a thread on clpmisc on writing 99 Bottles of Beer on the Wall in Perl. After exploring elegant solutions, posters turned to shorter solutions. At the time, the shortest solution took up three lines. With some spare time and nothing better to do, I recently succeeded in squeezing this program to two lines of Perl (fewer than 80 characters per line). Enjoy!
    on Nov 17, 2000 at 00:24 UTC
    by japhy
    This is a hangman game. It's not too frilly, but it's a nice efficient layout. Version 2 will be out soon, with a better data structure for the word list...
    Perl Hangman
    on Nov 16, 2000 at 19:04 UTC
    by Nimster
    A newbie's hangman in perl. Not the most effective, but works. Features are score, completion of the word from user input, and a slowly dying hangman. CGI version soon.
    on Nov 16, 2000 at 18:49 UTC
    by BastardOperator
    fortune program, nuff said.
    I just had to post this, not because of the code (~5 lines), but because of the quotes. They crack me up. :)
    VI in Perl
    on Nov 15, 2000 at 12:07 UTC
    by dmitri
    I am writing VI in Perl (vip), and I wanted to gather some comments. I post my code to the web site every 4-5 revisions. vip is almost usable now. Thanks for your input, people.
    Morse Code Converter
    on Oct 30, 2000 at 20:16 UTC
    by Octavian
    I was bored sitting around the office, and I felt like annoying a co-worker so I decided to write something up real quick that will email him messages in morse code. This code basically just converts whatever you give it as arguments into more code and emails it to the first argument. so you could do a ./convert this is a test of morse code. and it would send someperson the sentence in morse code
    Ghost (wordgame)
    on Oct 28, 2000 at 08:37 UTC
    by m_turner
    A variant simple word game described on Everything2

    The essence of the game is that players take turns adding letters to the begining or end of a group of letters. Winning is accomplished by either causing the other person to form part of a not-word, or create a complete word. It is a simple matter of programing to alter the heuristics to play the game as specified.

    I do admit that the heurstics could probably be improved several times.

    Web Based Chess Server
    on Sep 15, 2000 at 23:38 UTC
    by wombat
    A friend of mine recently learned that I suck at chess. (Only three people on the planet play worse than me) So she took it upon herself to try and teach me. Cordially, she offered to bring a chess set to a local coffeehouse where we could play amid the distraught oil paintings and the low jazz music playing in the background, but I had already gone and built this instead.

    What this will do, is allow two people to play a single game of chess, but it could be easily adapted to support multiple boards, (i.e a hidden field in the form code). It's not too hard to set up, and all one needs to do is provide images for the squares and the pieces. These are infinitely customizable. I crafted the pieces from pics of members of the Scifi club I'm involved in, (and it was immensly popular). To see how I set it up on my home machine, go here. I do however ask that you be kind and not move any of the pieces around. This is our game we're playing. Besides, I'll be able to tell if you do.

    There is limited error checking. Currently this version will check to see that it really is your turn to move, and that you're trying to actually move a piece (not empty space) and that you're not moving it off the board. However, it does not check for move legality. Thus, a person can in fact move the queen all the way across the board, jump the two rows of pawns, step once to the right, and take the opposing king on the very first move. I chose not to include error checking, because there are lots of different variations of chess thatdo not follow the rules. Most notably, "Fairy Chess" where the board wraps on the sides, (or is played on a 2D torus depending how you think about it.) So moves checking was left out to allow variations like that in.

    Again, I'm notoriously bad at chess. And the notation in the logs shows this. People have explained it all to me before, but it never took. I know about castleing, but you'll have to ask whoever the owner of the machine is to change the board when you want to do it. I've heard of "En Passant" passing by pawns, same thing, 'cept I have no clue about the rules surrounding that. In any case I hope you like it!

    The Name Game
    on Jul 19, 2000 at 22:36 UTC
    by Kozz
    Just a small bit of code to "do the name game" on any name given. I tried to clean up my code quite a bit to appease the monks before posting it, but I'm sure someone's got some ideas on how to improve it. :-)
    OL Crossword puzzle server/client
    on Aug 27, 2000 at 07:05 UTC
    by wombat
    This is an improvement over Adam's crossword puzzle generator. Each cell now conatins a 1 character text field, allowing you to actually fill it in and submit your answers to a site. The processing script is straightforward and one can program any number of events to happen when someone solves a puzzle (or submits an incorrect answer) :-). The one in the example is the same puzzle that was written by KM here. Since he said that he would post the answers in a few days, I shall refrain from including the solution in the code.

    Basically, in order to find the correct solution string to plug into the solution checker, you need to run each block's character together into one long string. It's ugly from a human standpoint, but it's easy to process. I hope to create a dynamic generator in the near future which would, from a list of words and corresponding clues automatically generate the grid, and thereby easily generate the solution string. Enjoy! ~W
    Crossword Table Maker
    on Aug 24, 2000 at 23:58 UTC
    by Adam
    I wrote this script to generate an html table of a crossword puzzle for KM. I figure that someone else might need to make a crossword puzzle into a table, so here it is.
    Cryptogram Generator
    on Feb 03, 2000 at 07:48 UTC
    by Elihu
    This takes a quote in the form of a small text file or a fortune with the '-f' flag and performs a (random) mono-alphabetic substitution cipher on it to create a cryptogram - just like the newspapers!
    Kris Kringle Script
    on Apr 28, 2000 at 02:44 UTC
    by Marburg

    Here is a little script that takes as input (STDIN) a :: field-delimited file of Names and associated Emails and emails everyone the name of the person they have to buy a present for. It is written in block format, just to make the perl students in my computer science department work a bit harder at figuring out how it works. There are no oddities, just plain Perl, and it should illustrate the way Perl can be used to solve problems.

    The basic idea is that the script shouls choose someone from the list for each person in the list but not themselves of course (who wants to buy a pressie for themselves?). Each person should be emailed their chosen present recipient and no details of the selection should be maintained ... the program includes a copy of itself for educational purposes!

    Anyway, could I have comments on improving the algorithm? Could I use a single Hash (appart from using a Hash of Lists)? Would it be better to shuffle a list and then select items one by one? Is there a better way than using grep to return the list of recipients? I have lots ot time to improve it before next Christmas.

    Enjoy it, please! Marburg. strip grabber
    on Mar 15, 2000 at 01:08 UTC
    by billyjoeray
    This script can be run on regular intervals to download the latest strips from I'm putting this here because its a little big for the front page, but for whoever reads this, I'd like some tips on how to clean up my code and some wisdom on how to easily write code with 'use scrict;' I always seem to be needing to use variables in a global sense. Full Size version forwarder :)
    on Mar 30, 2000 at 11:46 UTC
    by ash
    You hate having to load the small version of userfriendly for then to click on the link to the fullsize one? Well. This script forwards you directly to todays full size userfriendly strip :) But since userriendly doesn't update before 9 a.m in norway, i've inserted this little line: ($a[2]<9)&&$a[3]--; so that you'll be forwarded to yesterdays strip if it's not up yet. Change the 9 to your timezone :)
    Log In?

    What's my password?
    Create A New User
    Domain Nodelet?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (3)
    As of 2023-11-30 04:42 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found