diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-01-02 16:30:17 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-01-02 16:30:17 -0600 |
commit | e3146c09cde5168ab7be8fb563e854c2fb6cae0c (patch) | |
tree | 86c4d33c313aefdbf088200d02331042b9e88bb3 | |
parent | a23fd63c8c66dff93bc77ec3cc66aba984480b5a (diff) | |
download | bot-games-master.tar.gz bot-games-master.zip |
-rw-r--r-- | lib/Bot/Games/Game/24.pm | 5 |
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; |