AnyEvent-ReadLine-Gnu
view release on metacpan or search on metacpan
# works always, prints message to stdout
AnyEvent::ReadLine::Gnu->print ("message\n");
# now initialise readline
my $rl = new AnyEvent::ReadLine::Gnu prompt => "hi> ", on_line => sub {
# called for each line entered by the user
AnyEvent::ReadLine::Gnu->print ("you entered: $_[0]\n");
};
# asynchronously print something
my $t = AE::timer 1, 1, sub {
$rl->hide;
print "async message 1\n"; # mind the \n
$rl->show;
# the same, but shorter:
$rl->print ("async message 2\n");
};
# do other eventy stuff...
AE::cv->recv;
# works always, prints message to stdout
AnyEvent::ReadLine::Gnu->print ("message\n");
# now initialise readline
my $rl = new AnyEvent::ReadLine::Gnu prompt => "hi> ", on_line => sub {
# called for each line entered by the user
AnyEvent::ReadLine::Gnu->print ("you entered: $_[0]\n");
};
# asynchronously print something
my $t = AE::timer 1, 1, sub {
$rl->hide;
print "async message 1\n"; # mind the \n
$rl->show;
# the same, but shorter:
$rl->print ("async message 2\n");
};
# do other eventy stuff...
AE::cv->recv;
bin/rltelnet view on Meta::CPAN
my $len = sysread $fh, $rbuf, 1024, length $rbuf;
if ($len > 0) {
if ($rbuf =~ /\x0a$/) {
undef $tw;
$rl->hide;
print $rbuf;
$rl->show;
$rbuf = "";
} else {
$tw ||= AE::timer 0.2, 0, sub {
undef $tw;
$rl->hide;
print $rbuf;
print "...\n";
$rl->show;
$rbuf = "...";
};
}
} elsif (defined $len) {
print "$rbuf\nEOF received, exiting.\n";
( run in 1.107 second using v1.01-cache-2.11-cpan-49f99fa48dc )