<?xml version="1.0" encoding="windows-1252"?>
<node id="949213" title="Using AnyEvent with Term::ReadLine::Gnu" created="2012-01-21 22:18:07" updated="2012-01-21 22:18:07">
<type id="11">
note</type>
<author id="596967">
gnosti</author>
<data>
<field name="doctext">
Here is a solution that depends on Term::ReadLine::Gnu. 
&lt;p&gt;
&lt;code&gt;# Sample code showing how to integrate 
# Event with Term::ReadLine::Gnu (uses AnyEvent for watcher syntax)

use Term::ReadLine; # automatically loads Term::ReadLine::Gnu, 
                    # which must be present
use Event;
use AnyEvent;

my $term = new Term::ReadLine("Test Event");
my $attribs = $term-&gt;Attribs;
$term-&gt;callback_handler_install( "&gt; ", sub{ print "got: @_\n" });
my $stdin_watcher = AE::io(*STDIN, 0, 
	sub 
	{ 
		$attribs-&gt;{'callback_read_char'}-&gt;(); 
	}
);
my $timer = AE::timer(5,0, 
	sub
	{ 
		print "....timed out\n"; 
		$term-&gt;rl_deprep_terminal();
		exit;
	}
);
Event::loop();
__END__
&lt;/code&gt;
</field>
<field name="root_node">
948255</field>
<field name="parent_node">
948255</field>
</data>
</node>
