I took some of your code, some of my own and added in jeffa's summation snippet for good measure.
#! /usr/local/bin/perl use diagnostics; use warnings; use strict; use Games::Dice 'roll_array'; # this module rocks (well rolls anyway + ;-) use List::Util qw(sum); my $rolls = 6; for my $roll (1 .. $rolls) { # how many sets of dice rolls determin +ed by the value of $rolls my @rolls = roll_array '4d6'; # magic ;-) print "raw rolls: @rolls\n"; @rolls = sort @rolls; # sorted lowest to highest shift @rolls; # remove the lowest value by shifting +it off print "top three rolls: @rolls\n"; my $sum = sum(@rolls); # List::Util's sum print "total: $sum\n"; }
In reply to Re: Remove lowest number
by Mr. Muskrat
in thread Remove lowest number
by ellem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |