in reply to Re: Remove lowest number
in thread Remove lowest number
thus:my @num = (8, 9, 3, 5, 1, 2, 6, 7) ; my @all = sort { $b <=> $a } @num ;
So when I was writing this code:my $num5 = 5 ; my $num4 = 4 ; my $num3 = 3 ; my $num2 = 2 ; my @all = sort { $b <=> $a } $num4, $num2, $num5, $num3 ;
I thought I was sorting $d61 and I thought it might be hard to get at the lowest number inside $. Apparently I was wrong, but your code is over my head.my @d1s = sort { $b <=> $a } $d61 ;
Doesn't mean a lot to me. The whole $_ thing confuses me.$sum += $_ for @rolls;
#! /usr/local/bin/perl use diagnostics ; use warnings ; use strict ; use List::Util qw (sum) ; #not in the standard distro my $roll = 6 ; until ($roll == 0) { #rolls the dice 6 times $roll -- ; my @d61 = int(rand(5) + 2) ; #6 sided die with no 1 my @d62 = int(rand(5) + 2) ; my @d63 = int(rand(5) + 2) ; my @d64 = int(rand(5) + 2) ; my @all = sort #split line for looks { $b <=> $a } @d61, @d62, @d63, @d64 ; #sorts rolls #to prepare for pop @all ; #pop removing #the lowest roll my $sum = sum(@all) ; #before adding print "\n@all - $sum\n" ; }
|
|---|