#!/usr/bin/perl -wl # generates an ability score for use in D&D, with typical distribution my @rolls; push @rolls, 1+int rand 6 for 1..4; @rolls = sort sub {$_[0] <=> $_[1]}, @rolls; my $sum = 0; $sum += $rolls[$_] for 1..3; print $sum;