note
thmsdrew
<p>A new number will be generated when <code>roll</code> is called. If you want to get a new number, then the value, of "A" for example, needs to be updated each time you want to get it. Once it's stored in a hash, it's stored in a hash. Referring to the variable in the code won't update the value, even if you put the call to <code>roll("1d20")</code> directly into the hash, as in:</p><code>%hash = (
A => roll("1d20"),
B => roll("1d20"),
C => roll("1d20"),
); # As soon as you get to this point in the code, the value is stored (for good).</code>
<p>You need to figure out when you will want to store the value that was rolled, and when you will want to get a new value, and handle that accordingly. If the user wants to get a new "A" value, then you need to call <code>roll</code> again. If they want to get an old "A" value, then you need to refer to the value stored in the hash.</p>
<p>It seems like the point of the hash in your situation is to store things that don't dynamically change, but things that change as a result of the user doing something. However, if you want a roll to occur, you'll want a different mechanism for actually getting the roll, and the hash will be used just to store that roll.</p>
<p>I hope I am making sense.</p>
1003504
1003629