Commit | Line | Data |
51e1f1e1 |
1 | #!/usr/bin/env perl |
2 | |
6f914695 |
3 | use strictures 1; |
4 | use Eval::WithLexicals; |
5 | use Term::ReadLine; |
51e1f1e1 |
6 | use Data::Dumper; |
8d732f30 |
7 | use Getopt::Long; |
8 | |
9 | GetOptions( |
10 | "plugin=s" => \my @plugins |
11 | ); |
51e1f1e1 |
12 | |
13 | $SIG{INT} = sub { warn "SIGINT\n" }; |
14 | |
15 | { package Data::Dumper; no strict 'vars'; |
16 | $Terse = $Indent = $Useqq = $Deparse = $Sortkeys = 1; |
17 | $Quotekeys = 0; |
18 | } |
6f914695 |
19 | |
8d732f30 |
20 | my $eval = @plugins |
21 | ? Eval::WithLexicals->with_plugins(@plugins)->new |
22 | : Eval::WithLexicals->new; |
23 | |
6f914695 |
24 | my $read = Term::ReadLine->new('Perl REPL'); |
25 | while (1) { |
26 | my $line = $read->readline('re.pl$ '); |
27 | exit unless defined $line; |
51e1f1e1 |
28 | my @ret; eval { |
6f914695 |
29 | local $SIG{INT} = sub { die "Caught SIGINT" }; |
51e1f1e1 |
30 | @ret = $eval->eval($line); 1; |
31 | } or @ret = ("Error!", $@); |
6f914695 |
32 | print Dumper @ret; |
33 | } |