From: Matt S Trout Date: Sun, 5 Dec 2010 16:55:50 +0000 (+0000) Subject: clean up example to not require extra modules X-Git-Tag: v1.000000~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FEval-WithLexicals.git;a=commitdiff_plain;h=51e1f1e1c713c85f5140ee7776d13b7d5726505b clean up example to not require extra modules --- diff --git a/bin/tinyrepl b/bin/tinyrepl index 352ad97..236b081 100755 --- a/bin/tinyrepl +++ b/bin/tinyrepl @@ -1,19 +1,25 @@ +#!/usr/bin/env perl + use strictures 1; use Eval::WithLexicals; use Term::ReadLine; -use Data::Dumper::Concise; -use Try::Tiny; +use Data::Dumper; + +$SIG{INT} = sub { warn "SIGINT\n" }; + +{ package Data::Dumper; no strict 'vars'; + $Terse = $Indent = $Useqq = $Deparse = $Sortkeys = 1; + $Quotekeys = 0; +} my $eval = Eval::WithLexicals->new; my $read = Term::ReadLine->new('Perl REPL'); while (1) { my $line = $read->readline('re.pl$ '); exit unless defined $line; - my @ret; try { + my @ret; eval { local $SIG{INT} = sub { die "Caught SIGINT" }; - @ret = $eval->eval($line); - } catch { - @ret = ("Error!", $_); - }; + @ret = $eval->eval($line); 1; + } or @ret = ("Error!", $@); print Dumper @ret; }