#!/usr/bin/perl -w use strict; use warnings; use diagnostics; my @rolls=(); foreach (0..7){ $rolls[$_]=d2d6(); } my @keys=sort {$a cmp $b} @rolls; my %ptr=map { $_ => 1 } @keys; $ptr{$keys[0]}=0; my @cull = grep $ptr{$_} ,@rolls; print "Sorted: ",join(" ",@keys),"\n"; print "Before culling: ",join(" ",@rolls),"\n"; print "After culling: ",join(" ",@cull),"\n"; exit(0); sub d1d6 { return int(rand(6))+1; } sub d2d6 { return d1d6() + d1d6(); }