6 use JSON::PP qw(encode_json decode_json);
9 if (my $host = $ARGV[0]) {
10 'cat jsonrepl.packed - | ssh '.$host.' perl -'
16 my $pid = open2(my $out, my $in, $cmd);
18 my $read = Term::ReadLine->new('REPL');
21 my $line = $read->readline('re.pl$ ');
22 exit unless defined $line;
23 next unless length $line;
24 print $in encode_json([ EVAL => $line ])."\n";
25 my $reply = decode_json scalar readline($out);
26 if ($reply->[0] eq 'MISTAKE') {
27 die "Botch: ".join(': ', @{$reply}[1,2]);
29 my $ret = $reply->[1];
32 chomp($ret->{stdout});
33 print "STDOUT:\n${\$ret->{stdout}}\n";
36 chomp($ret->{stderr});
37 print "STDERR:\n${\$ret->{stderr}}\n";