diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-05-29 02:28:58 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-05-29 02:50:30 -0500 |
commit | 5b9c3c3f7bab2a1b02faf8fcf0f4e804f621891a (patch) | |
tree | 240b22cf6010c43c059aeba0160abe1955a3eaf4 /lib/App/REPL.pm | |
parent | 04dfe92390c4f80db3c6672f75c233476affe847 (diff) | |
download | reply-5b9c3c3f7bab2a1b02faf8fcf0f4e804f621891a.tar.gz reply-5b9c3c3f7bab2a1b02faf8fcf0f4e804f621891a.zip |
use eval::closure instead
Diffstat (limited to 'lib/App/REPL.pm')
-rw-r--r-- | lib/App/REPL.pm | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/App/REPL.pm b/lib/App/REPL.pm index 4c8110a..916e60c 100644 --- a/lib/App/REPL.pm +++ b/lib/App/REPL.pm @@ -6,6 +6,7 @@ use App::REPL::Plugin::Defaults; use Module::Runtime qw(compose_module_name use_package_optimistically); use Scalar::Util qw(blessed); +use Try::Tiny; sub new { bless { @@ -44,13 +45,13 @@ sub run { my $self = shift; while (defined(my $line = $self->_read)) { - my @result = $self->_eval($line); - if ($@) { - $self->_print_error($@); - } - else { + try { + my @result = $self->_eval($line); $self->_print_result(@result); } + catch { + $self->_print_error($_); + } } print "\n"; } |