Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by Laurent_R (Parson)
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: (7)
As of 2014-08-30 16:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls