Wednesday, August 10, 2005

Perl Program

Those of you who have a Perl compiler, and like to randomize everything (like I do) might enjoy this little perl script I wrote last night during the Mariners game. It basically generates a practice routine for you that is different every time. It takes one argument, and that is the number of practice games you wanna play. You will obviously need to change the content of the arrays to suit your dart collection and your favorite practice games, but this little program will certainly "keep it fresh" for you.

The usage is as such: $ ./ 9

In this example '9' is the single argument indicating that you'd like a list of nine random practice games. The default argument is 1. So if you just type '' at the prompt with no argument at all it will give you a single practice game.

This is what the output looks like:

========================= begin
#! /usr/bin/perl

$sets = $ARGV[0] || 1;

@dart_sets = (
'27g Razors',
'24g Merv Kings',
'16g Unicorns',

@practice_games = (
'Three 101\'s',
'SIDO 501',
'DIDO 301',
'Paul Williams Challenge',
'20 Bulls',
'20 Sixties',

for ($i=1; $i <= $sets; $i++) {

$index1 = rand @dart_sets;
$darts = $dart_sets[$index1];

$index2 = rand @practice_games;
$game = $practice_games[$index2];

print "$i. play $game with $darts\n";

========================= end

No comments: