Would this help?
#!/usr/bin/perl -slw use strict; use Tk; use AnyEvent; use POSIX qw(:sys_wait_h); use Term::ReadLine; use IO::File; use 5.12.1; sub LOG { state $fh; open $fh, '>', '/tmp/sopw.out' unless $fh; die $! unless $fh; autoflush $fh 1; say $fh @_; } package Term::ReadLine::AE; unshift @Term::ReadLine::Stub::ISA, __PACKAGE__; #use Data::Dump qw(ddx); #ddx(\%INC); if ( not defined &Tk::DoOneEvent ) { ::LOG("overriding"); *Tk::DoOneEvent = sub { AnyEvent->_poll(); }; ::LOG("Not created?") unless defined &Tk::DoOneEvent; } our $cv; sub Tk_loop { my $self = shift; ::LOG("Entering Tk_loop"); $cv = AE::cv; $cv->recv(); } sub register_Tk { my $self = shift; ::LOG("Registering"); $Term::ReadLine::registered++ or AE::io( $self->IN, 0, sub { $cv->send() } ); } package main; use 5.12.1; my $esc; BEGIN { $esc = "\x1b["; print "${esc}2J"; } my $t = 0; my $w = AE::timer( 0, 1, sub { print "${esc}s${esc}1H$t s ${esc}u"; +++$t } ); my $term = Term::ReadLine->new('AE'); my $OUT = $term->OUT || \*STDOUT; my $prompt = "Finished"; my $cmd; while (defined( $cmd = $term->readline('>') )) { my @output = `$cmd`; my $exit_value = $? >> 8; my $signal_num = $? & 127; my $dumped_core = $? & 128; printf $OUT "Program terminated with status %d from signal %d%s\n" +, $exit_value, $signal_num, $dumped_core ? " (core dumped)" : ""; say @output; $term->addhistory; $term->tkRunning(1); say $prompt; exit; }

In reply to Re: Using Term::ReadLine in an event loop other than Tk by Khen1950fx
in thread Using Term::ReadLine in an event loop other than Tk [SOLVED] by Tanktalus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.