For the random weapon thing, you could probably pick a random index out of an array -- ie, something like:
Code:
my @nums = (55261,24773,25989,22982,26031,54065,43148,7823);
srand();
my $weapon = $nums[int(rand() * ($#nums + 1))];
print "random weapon: $weapon\n";