[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] timeout for STDIN?



In the code below I would like to allow about 10 seconds for STDIN from
user keyboard and if nothing is sent in that time to have the call for
STDIN supplanted by a \n to $_.  Is this doable?

Thanks, 
Ken Truitt

----------------------------------------------------------------------
while (1) {
   $_ = <STDIN>;      #<--- need 10 second wait here

#I don't think the rest is really relevent, just for reference#

   if ($_ =~/^\$\d*,\d*$/ || $_=~/^\$[A-Z][a-z]+/) {
    $_=~s/\$//;
    &SEARCH($_,'CIS');
   }
   if ($_=~/NO\sCARRIER/) {&DISCONNECT;}
   print &CommConnect'Send($_);
   sleep 2;
   $output = &CommConnect'Receive();
   $output =~tr/\012\015/\n/s;
   $back = &BUFFOMATIC($output,'CIS');
   @OUTPUT = split(/\n/,$output);
   shift @OUTPUT;
   for ($i=0;$i<=$#OUTPUT;$i++) {
    if ($i!=($#OUTPUT) && $OUTPUT[$i]) {
     print STDOUT "$OUTPUT[$i]\n";
    }
    else {
     print STDOUT "$OUTPUT[$i]";
    }
  }
}

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch