From: Matt S Trout Date: Fri, 28 Oct 2011 18:48:44 +0000 (+0000) Subject: allow jreplclient repl to be packed into __DATA__ X-Git-Tag: v0.001001~38 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ac134649b64cae32203281cc3b40b612e4a07d7e;p=scpubgit%2FTak.git allow jreplclient repl to be packed into __DATA__ --- diff --git a/jreplclient b/jreplclient index 1ebeaee..82e113b 100644 --- a/jreplclient +++ b/jreplclient @@ -7,14 +7,25 @@ use JSON::PP qw(encode_json decode_json); my $cmd = do { if (my $host = $ARGV[0]) { - 'cat jsonrepl.packed - | ssh '.$host.' perl -' + 'ssh '.$host.' perl -' } else { - 'perl jsonrepl' + 'perl -' } }; my $pid = open2(my $out, my $in, $cmd); +{ + my $jr; + if (!eof(*DATA)) { + $jr = \*DATA + } else { + open $jr, '<', 'jsonrepl.packed' or die "No packed repl: $!"; + } + while (<$jr>) { print $in $_ } + print $in "__END__\n"; +} + my $read = Term::ReadLine->new('REPL'); while (1) {