[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] perl non-blocking STDIN



Hans Schou wrote:
> select RBITS, WBITS, EBITS, TIMEOUT

Tak for sparket i den rigtige retning!

Jeg fik det til at virke med følgende kode, det
krævede godt nok en hel del eksperimenteren.
Brugen af <STDIN> er vist ikke helt rent i kanten,
da den mixer rå access (select) med perls buffered IO.

#!/usr/bin/perl

$wait=0.5;

$rin=''; vec($rin,fileno(STDIN) ,1)=1;

$tick=0;
while (42==42)
{
   $nfound=select($rout=$rin,undef,undef,0);

   if ($nfound)   #process input
      {
         $_=<STDIN>; chomp;
         print "$tick:$_\n";
      }
    else          #run background
      {
      }
   
   $tick++;
   select(undef,undef,undef,$wait);
}

-- 
  Mvh. Carsten Svaneborg
http://gauss.ffii.org


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-11-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *