in reply to Six-side dice roll calculator

Thought I'd dump my script here too! Input lines in 3d6, 1d20, 2d4 format :-)

It even support the wonderful d3 format for those side of the coin landings!
#!/usr/bin/perl use strict; use warnings; while (<>){ next unless my ($number, $sides) = ($_ =~ /^(\d+)d(\d+)$/); my $total = 0; for (1..$number){ my $roll = int(rand($sides)+1); print "$roll "; $total += $roll; } print "($total)\number"; }