Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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

by Laurent_R (Monsignor)
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?

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 chanting in the Monastery: (3)
As of 2015-11-29 22:18 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (753 votes), past polls