sub roll{ my ($a)=@_; #chop($a); ($b,$constant)=split(/\+|\-/,$a); ($number,$dice)=split(/[dD]/, $b); if ($constant==''){ $constant=0; } if($a=~ m/\-/){ $constant*=(-1); } $count=0; for ($c=1; $c<=$number; $c++){ $d[$c]=int(rand($dice))+1; $count += $d[$c]; } $count += $constant; if ($count<0){ $count=0; } return "$count"; } $A=roll("1d20"); $B=roll("1d20"); $C=roll("1d20"); print "BEFORE HASH:$A\t$B\t$C\n"; %hash= ( A => "$A", B => "$B", C => "$C", ); print "What would you like to know?\n\n"; $type=; chomp($type); until ($type eq "Q"){ #print "You typed .$type.\n"; print "\n\n$type: $hash{$type}\n"; print "What would you like to know?\n\n"; $type=; chomp($type); }