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/thread-self/root/usr/share/doc/perl-Event/demo/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/proc/thread-self/root/usr/share/doc/perl-Event/demo/echo.t
#!/usr/bin/perl -w

$| = 1;
use Event qw(time);
require Event::io;

print "This demo echoes whatever you type.  If you don't type anything
for as long as 2.5 seconds then it will complain.  Enter an empty line
to exit.

";

my $recent = time;
Event->io(fd      => \*STDIN,
          timeout => 2.5,
          poll    => "r",
          repeat  => 1,
          cb      => sub {
	      my $e = shift;
	      my $got = $e->got;
              #print scalar(localtime), " ";
	      if ($got eq "r") {
		  sysread(STDIN, $buf, 80);
		  chop $buf;
		  my $len = length($buf);
		  Event::unloop if !$len;
		  print "read[$len]:$buf:\n";
		  $recent = time;
	      } else {
		  print "nothing for ".(time - $recent)." seconds\n";
	      }
          });

Event::loop();

Hry