Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: New to Perl: Hashes and int(rand())by davido (Cardinal) |
on Jun 14, 2014 at 06:42 UTC ( [id://1089873]=note: print w/replies, xml ) | Need Help?? |
The reason it prints three times is that you moved the "print" statement into the loop's body, so on each loop iteration, it prints. Unfortunately, since you modified the HERE doc, you can't just move the print outside of the loop, because the $true variable won't be in scope. Even if it were in scope, it would print the same value for strength, intelligence, and dexterity, since it only contains one value. The easiest solution is to revert to the template that the book gave you (namely, the HERE doc should look like this:
...and so on). Once you've made that change, you can change this line:
...to this...
Dave
In Section
Seekers of Perl Wisdom
|
|