/[Sack]/trunk/lib/Sack/REPL.pm
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/lib/Sack/REPL.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 183 - (show annotations)
Sun Nov 8 13:03:54 2009 UTC (14 years, 7 months ago) by dpavlin
File size: 865 byte(s)
tweak output and put into package

1 #!/usr/bin/perl
2
3 package Sack::REPL;
4
5 use warnings;
6 use strict;
7
8 use Term::ReadLine;
9 use IO::Socket::INET;
10 use Storable qw();
11 use Data::Dump qw(dump);
12
13 my $retries = 0;
14 my $sock;
15
16 print STDERR "wait for server";
17
18 while ( $retries < 10 && ! $sock ) {
19 $sock = IO::Socket::INET->new(
20 PeerAddr => '127.0.0.1',
21 PeerPort => 4444,
22 Proto => 'tcp',
23 );
24 if ( ! $sock ) {
25 $retries++;
26 print STDERR ".";
27 sleep 1
28 }
29 }
30
31 die $! unless $sock;
32
33 print STDERR "\nconnected after $retries retries\n";
34
35 Storable::fd_retrieve( $sock )->{ping} or die "no ping";
36
37 my $term = Term::ReadLine->new('Sack');
38 my $prompt = "sack> ";
39 my $OUT = $term->OUT || \*STDOUT;
40 while ( defined ($_ = $term->readline($prompt)) ) {
41 if ( /\S/ ) {
42 warn "# $_\n";
43 Storable::store_fd( { repl => $_ }, $sock );
44 warn "## ", dump( Storable::fd_retrieve( $sock ) );
45 $term->addhistory($_);
46 }
47 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26