/[Sack]/trunk/experiments/protocol-v3/repl.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/experiments/protocol-v3/repl.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 164 - (show annotations)
Sun Nov 1 21:00:30 2009 UTC (14 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 611 byte(s)
added external read-eval-loop readline interface

1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use Term::ReadLine;
7 use IO::Socket::INET;
8 use Storable qw();
9 use Data::Dump qw(dump);
10
11 my $sock = IO::Socket::INET->new(
12 PeerAddr => '127.0.0.1',
13 PeerPort => 4444,
14 Proto => 'tcp',
15 ) || die $!;
16
17 Storable::fd_retrieve( $sock )->{ping} or die "no ping";
18
19 my $term = Term::ReadLine->new('Sack');
20 my $prompt = "sack> ";
21 my $OUT = $term->OUT || \*STDOUT;
22 while ( defined ($_ = $term->readline($prompt)) ) {
23 if ( /\S/ ) {
24 warn "# $_\n";
25 Storable::store_fd( { repl => $_ }, $sock );
26 warn "## ", dump( Storable::fd_retrieve( $sock ) );
27 $term->addhistory($_);
28 }
29 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26