#!/usr/bin/perl -w use strict srand( time() ^ ($$ + ($$ << 15)) ); # Written by Jim Schweizer for TLUG's hardware raffle. # The list file should contain the name of each ticket buyer. # There can be as many different raffles as you want - just # write a new list for each one or reuse a list. # The format of the list file is one name per line. print "\nWhat is the name of your list file? "; chomp($ticket = ); # Get the ticket buyers from the file. open(FILE,"$ticket") || die "Can't find the file you typed!\n\n"; @cooldudes = ; close(FILE); print "\nLet's get started.\n\n"; # Find out what the prize is. print "What prize do you want to give away? "; chomp ($prize = ); print "\nIf you wish to pick a name use 'yes' or 'y'.\n\n"; @prompts = ("Shall we pick a name? ", "Let's get a winner? ", "Pick a $prize winner? ", "Grab a name from the hat? ",); while () { # get a prompt $prompt = rand(@prompts); print "$prompts[$prompt]"; chomp ($more = ); if ($more =~ m/\byes\b|\by\b/){ # get a winner from @cooldudes $win = rand(@cooldudes); chomp ($win); # print the random winner print "\nGive a $prize to $cooldudes[$win]\n"; # take the winner out of the array splice(@cooldudes, $win, 1); # check to see if any cool dudes remain if (@cooldudes >0){ # see how many are left $numdudes = (@cooldudes); print "There are still $numdudes of you waiting.\n\n"; } else{ # or wrap it up print "\aThat's all folks.\n\n"; exit } } else{ # not a 'yes' or 'y' input so we're leaving die "\a\nThanks for playing. Too bad: @cooldudes didn't get a $prize.\n\n"; } }