Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tlug: raffling the Sparc



Hi all,

Craig's question about using a random number for raffling off the door prizes
has been a real motivator for me to learn more about perl. 

Thanks to Jim T. and his help, I spent some more time on this and came up with a
more 'perlesque' solution. There are two drawbacks to this script - someone has
to enter the names into the @example.com array when they buy a raffle ticket, and
I don't (yet) know how to break the loop when @example.com is empty. 

As always, I appreciate the feedback from all of you.

rand.pl for raffling off the Sparcs:

-------cut here---------------------------
#!/usr/bin/perl -w
use strict
srand( time() ^ ($$ + ($$ << 15)) );

# get the names of TLUGers present
@example.com = ("Craig",
              "Steve",
              "Casmar",
              "Damien",
              "Jim T.",
              "Blaine",
              "Jason",
              "Joe",
              "John",);

print "\nLet's get started.\n@example.com have all bought tickets.\n\n";

while () {
print "Shall we pick a name? ";
chop ($more = <STDIN>);
if ($more eq "yes") {

#get a winner from @example.com 
$win = rand(@example.com);

#print the random winner 
print "\nGive $cooldudes[$win] a Sparc.\n";
splice(@example.com, $win, 1);

print "The losers were @example.com";

}
else{
exit;
}}
--------------cut-------------------------------

I know there's a lot more that could be done with a script like this....
(but, hey, not bad for a simple country English teacher;-)

Thanks,

Jim S.

----------------------------------
Jim Schweizer <schweiz@example.com> 
sent this on 21-Nov-97 at 23:20:13
It is much easier to suggest solutions when you 
know nothing about the problem.
http://www1.harenet.or.jp/~schweiz/
----------------------------------
---------------------------------------------------------------
TLUG Meeting Dec. 13, 12:30 at Tokyo station Yaesu Chuo ticket gate
13:30 Starbuck's coffee.  13:45 HSBC | info: joem@example.com
At least 3 functional Sparc IPC machines will be raffled out
---------------------------------------------------------------
a word from the sponsor:
TWICS - Japan's First Public-Access Internet System
www.twics.com  info@example.com  Tel:03-3351-5977  Fax:03-3353-6096



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links