Subject: | new() has regex error that limits it to die with less than 10 faces |
I was playing around with Games::Dice::Advanced and wanted to try
something with a 20 sided die, but it comes out as a 1 sided die:
<pre>
#!/usr/bin/perl
use Games::Dice::Advanced;
foreach ( 1..10 )
{
print Games::Dice::Advanced->roll( "d20" ), "\n";
}
</pre>
There's a closing paren in the wrong place in the regex to parse that:
<pre>
--- Advanced.pm 2006-09-10 10:45:33.000000000 -0500
+++ Advanced.pm-new 2006-09-10 10:46:51.000000000 -0500
@@ -132,7 +132,7 @@
if($recipe !~ /\D/) { # constant
# $self = eval("sub { $recipe * $mul }");
$self = sub { $recipe * $mul };
- } elsif($recipe =~ /^d(\d)+$/) { # dINT
+ } elsif($recipe =~ /^d(\d+)$/) { # dINT
# $self = eval("sub { (1 + int(rand($1))) * $mul }");
my $faces = $1;
$self = sub { (1 + int(rand($faces))) * $mul };
</pre>