in reply to Dice roll chances
Hi, don't forget to be a bit poetic. You're writing Perl.
Update: edited to output the sum of random numbers on one line, misunderstood the spec. Still somewhat poetic, I hope.
use strict; use warnings; use feature 'say'; sub num { my $num = int( rand( 50 ) + 1 ); $num } sub sum { my $sum = 0; $sum += $_ for @_; $sum } say sum map { num } 1 .. 5 until not 'fun'; __END__
Hope this helps ;-)
|
|---|