Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: New to Perl: Hashes and int(rand())

by Laurent_R (Abbot)
on Jun 14, 2014 at 08:09 UTC ( #1089879=note: print w/replies, xml ) Need Help??

in reply to New to Perl: Hashes and int(rand())

This is an (untested) example of the code you might want to insert into the program template provided by Ovid in order to populate the %stat_for hash:
foreach my $key (keys %stat_for) { $stat_for{$key} = 2 + int (rand (6)) + int (rand (6)); }
This will populate different random values for each of the three characteristrics (intelligence, strength, dexterity) of your character, because the $key variable will take successively the values of the three caracteristics.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1089879]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2016-10-25 17:45 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (326 votes). Check out past polls.