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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.