Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by Laurent_R (Prior)
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.


Comment on Re: New to Perl: Hashes and int(rand())
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2015-07-05 22:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls