summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2010-01-02 16:30:17 -0600
committerJesse Luehrs <doy@tozt.net>2010-01-02 16:30:17 -0600
commite3146c09cde5168ab7be8fb563e854c2fb6cae0c (patch)
tree86c4d33c313aefdbf088200d02331042b9e88bb3
parenta23fd63c8c66dff93bc77ec3cc66aba984480b5a (diff)
downloadbot-games-e3146c09cde5168ab7be8fb563e854c2fb6cae0c.tar.gz
bot-games-e3146c09cde5168ab7be8fb563e854c2fb6cae0c.zip
cleanupsHEADmaster
-rw-r--r--lib/Bot/Games/Game/24.pm5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Bot/Games/Game/24.pm b/lib/Bot/Games/Game/24.pm
index e461a96..6d8b68e 100644
--- a/lib/Bot/Games/Game/24.pm
+++ b/lib/Bot/Games/Game/24.pm
@@ -4,6 +4,7 @@ use Bot::Games::OO;
use List::Util qw/shuffle/;
use Math::Expression::Evaluator;
use Time::Duration;
+use Try::Tiny;
has '+help' => (
default => '24 help',
@@ -96,8 +97,8 @@ sub generate_24 {
sub evaluate {
my $self = shift;
my ($expr) = @_;
- return undef unless $expr =~ /^[-\d\+\*\/\(\)]+$/;
- return eval { Math::Expression::Evaluator->new->parse($expr)->val };
+ return unless $expr =~ /^[-\d\+\*\/\(\)]+$/;
+ return try { Math::Expression::Evaluator->new->parse($expr)->val };
}
__PACKAGE__->meta->make_immutable;