No such thing as a small change | |
PerlMonks |
D20 dice throw parserby Luca Benini (Scribe) |
on Dec 17, 2004 at 13:40 UTC ( [id://415624]=CUFP: print w/replies, xml ) | Need Help?? |
This code snippet contains a bug free(R) expression allowing you to parse D20 notation dice, so you can parse strings like 3D6,3D6+4 and 3D6+4x1000 obtaining as result (for 3D6+4x1000):
$dtime = 3 $dface = 6 $addfact = 4 $mulfact = 1000 The snippet set also right default value is a field is missing, so you can use returned value directly for calculation
Back to
Cool Uses for Perl
|
|