From e3146c09cde5168ab7be8fb563e854c2fb6cae0c Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 2 Jan 2010 16:30:17 -0600 Subject: cleanups --- lib/Bot/Games/Game/24.pm | 5 +++-- 1 file 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; -- cgit v1.2.3