in reply to Re: Remove lowest number
in thread Remove lowest number

First let's understand that I have no idea what I am doing and only a murky idea of what I want to do!

OK I'll give you the chomp I think that had something to do with an older version of this. See mostly I make Perl read logs and take data from different sources and shove it all together. But I don't do this everyday and as such I suck at it.

OK, so I thought:
my @num = (8, 9, 3, 5, 1, 2, 6, 7) ; my @all = sort { $b <=> $a } @num ;
thus:
my $num5 = 5 ; my $num4 = 4 ; my $num3 = 3 ; my $num2 = 2 ; my @all = sort { $b <=> $a } $num4, $num2, $num5, $num3 ;
So when I was writing this code:
my @d1s = sort { $b <=> $a } $d61 ;
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.
$sum += $_ for @rolls;
Doesn't mean a lot to me. The whole $_ thing confuses me.

UPDATE:

I really looked at this answer, suggestion and I started commenting things out to see which part of my code was really useless. Here's what is left:
#! /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" ; }

--
ellem@optonline.net
There's more than one way to do it, but only some of them actually work.