#!/usr/bin/perl -w #Given an attribute value, return the step. sub step { my $attribute = shift; return (($attribute-1)-($attribute-1)%3)/3+2; } #Array of attribute costs indexed by attribute value @attr=(-67,-67,3,2,1,0,-1,-2,-3,-4,-5,-6,-8,-10,-13,-16,-19,-21,-23,-67,-67,-67,-67,-67,-67,-67,-67,-67,-67,-67); #Racial attribute modifier %race=( 'dwarf' => [0,2,3,0,0,-1], 'elf' => [2,0,-2,1,1,1], 'human' => [0,0,0,0,0,0], 'obsidiman' => [-2,6,4,-1,0,-1], 'ork' => [-1,3,1,0,-1,-1], 'troll' => [0,4,2,-1,1,0], 'tskrang' => [1,0,1,0,0,1], 'windling' => [1,-4,-3,1,0,2]); #Attribute names @attrn=( 'Dexterity', 'Strength', 'Toughness', 'Perception', 'Willpower', 'Charisma'); #Assumes an attribute allowance of 66 points. $tot=66; #Clean up input $ARGV[6] =~ tr/[A-Z]/[a-z]/; $ARGV[6] =~ s/[^a-z]//g; #Total up the cost. for ($i=0 ; $i<6 ; $i++) { $tot+=$attr[$ARGV[$i]-${$race{$ARGV[6]}}[$i]]; } #Print out stuff. format STDOUT_TOP = Points left: @<<< $tot Attribute Step Racial Modifier . format STDOUT = @<<<<<<<<<<<<<< @<<<<<<<< @<<< @<<<<<<<<<<<<<< $attrn[$i], $ARGV[$i], step($ARGV[$i]), ${$race{$ARGV[6]}}[$i] . for ($i=0; $i<6; $i++) { write; }