in reply to Re: What the other half does
in thread What the other half does

Another way of doing the same thing:
#!/usr/bin/perl use strict; ##################### Script Constants ###################### use constant CHARACTER_STATS => qw(Strength Intelligence Wisdom Dexter +ity Constitution Charisma); ################### Main Program ############################ MAIN: { my $character = make_character(); foreach my $stat (keys %$character) { print STDOUT ("$stat: \t\t", join("\t", @{ $character->{$stat} }), "\n" ); } } sub make_character { my $character = {}; for (my $x = 0; $x<=5; $x++) { foreach my $stat ( CHARACTER_STATS ) { push(@{$character->{$stat}}, Random()); } } return $character; } sub Random () { return (int (rand(18))+1); }
If you're interested in having the dice follow a normal distribution, check out the Math::Random module.

stephen