http://qs1969.pair.com?node_id=1174699


in reply to Dungeons and Dragons die roller (Golf)

Straightforward 39 bytes (37 + 2 flags) solution :
#!perl -pl /\d+\+/;$-+=rand$&for 1..$_;$_+=$'+$-
More complex 35 bytes solution :
#!perl -pl s/d/q(+~~rand($')+d)x$`/e;$_=eval
Due to the use of $', they canít easily be ran from the command-line. Just store them in a file.