60 byte solution, not counting hashbang, to take strings that look like '2d4' or '2d4+10' and give you the result:
-n ($d,$s,$=)=split/d|\+/;$=+=1+rand $s for 1..$d;print$=,$/ [download]
Anyone wants to try and beat my record?
-p ($d,$s,$=)=split/[d+]/;map$=+=1+rand$s,1..$d;$_=$=.$/ 1 2 3 4 5 12345678901234567890123456789012345678901234567890123 [download]
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a, [download]
#!perl -pl /\d+\+/;$-+=rand$&for 1..$_;$_+=$'+$- [download]
#!perl -pl s/d/q(+~~rand($')+d)x$`/e;$_=eval [download]
~~rand($') is the same as int(rand($'))
That produces the same result every 'roll' it seems...
That's strange, I tested it out and it worked fine. I'm using v5.18.2, what are you using?
To steal choroba's post:
echo 2d12+13 | \ perl -ple ' ($d,$s,$_)=split/[d+]/;map$_+=1+rand$s,1..$d ' 1 2 3 4 12345678901234567890123456789012345678901234 [download]