#! /usr/bin/perl -w use CGI; my $q = new CGI; my @action = split(/,\s*/, q[Drinking, Flirting/Seducing, Intimidate/Threaten, Demanding/Robbing, Ignoring, Honoring, Bribing (gold/magic item/food/etc.), Trade, Question/Interrogate, Pray/Convert, Seek Aid, Offer Aid, Surrender/Grovel, Flee, Gambling]); my @reward = split(/,\s*/, q[Teach a spell, Tell about another NPC/Faction, Join the party, Give a quest, Hand over a reward, Tell about a trap, Hand over a map, Act as a guide to somewhere, Teach a skill, Unlock a playable race, Unlock a new special ability]); sub one { my $ref = shift; my $i = int(rand(@$ref)); # print $q->p(join(', ', @$ref), $i . '/' . @$ref); return splice(@$ref, $i, 1); } sub items { my $n = shift; my @item = (); while ($n-- > 0) { push(@item, [one(\@action), one(\@reward)]); } return @item; } sub main { print $q->header(); print $q->start_html("Non-Player Characters"); print $q->h1("Non-Player Characters"); foreach my $item (items(4)) { print $q->p($item->[0] . ": " . $item->[1]); } } main();