Though the node title implies otherwise, it would appear that the OP isn't generating random die rolls, but calculating the average die roll from 4d6 drop the lowest.
It probably sounds like a silly sort of thing, but as a gamemaster, I have actually found myself working out what the average roll for a given group of dice is, and what the percentage chance of any given number from a given group of dice, for the purpose of crafting a random roll chart.
And here's my simplified version, I decided to stick with the nested for loops so as to stay with the methodology of the OP's code, also, instead of counting iterations, I just did 6**4, since the number of iterations won't change.
#!/usr/bin/perl
use warnings;
use strict;
my $total;
for my $i (1..6) {
for my $j (1..6) {
for my $k (1..6) {
for my $l (1..6) {
# get the sum for this dice-roll
my @roll = (sort ($i, $j, $k, $l))[1..3];
$total += eval join '+', @roll ;
}}}}
print $total/6**4
or, if you'd prefer, as a (somewhat unwieldy) one-liner:
for $i(1..6){for $j(1..6){for $k(1..6){for $l(1..6){$total+=eval join '+',(sort($i,$j,$k,$l))[1..3]}}}}print $total/6**4 |