start: die /^\Z/ {$item [1]} die: 'd' number {1 + int rand $item [2]} | number 'd' number {my $s = 0; foreach (1 .. $item [1]) { $s += 1 + int rand $item [3] } $s} number: /\d+/
In [1] := d3 Out [1] = 1 In [2] := d3 Out [2] = 2 In [3] := 2d4 Out [3] = 4 In [4] := 3 d 5 Out [4] = 7 In [5] := 3d5 Out [5] = 8 In [6] := foo Out [6] = <<UNDEF>>