home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / perl / 6876 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  1.5 KB

  1. Path: sparky!uunet!ukma!wupost!usc!news!netlabs!lwall
  2. From: lwall@netlabs.com (Larry Wall)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: $| for stdin?
  5. Keywords: stdin $| and life
  6. Message-ID: <1992Nov6.203330.22254@netlabs.com>
  7. Date: 6 Nov 92 20:33:30 GMT
  8. References: <1992Nov4.235759.14315@utagraph.uta.edu>
  9. Organization: NetLabs, Inc.
  10. Lines: 21
  11.  
  12. In article <1992Nov4.235759.14315@utagraph.uta.edu> turbo@cse.uta.edu (Chris Turbeville) writes:
  13. : I am looking for some way of clearing standard in before every read.
  14. : You know the stdin counter-part of $|.  I have a large program
  15. : responsable for helping non-unices do unix admin things safely but I
  16. : can't seem to keep it from getting a wrong char occasionally.  If the
  17. : enter key is a little sticky then I get default responses when they may
  18. : have wanted to enter something just because their fingers are a little
  19. : heavy.  Does anyone know of a way to flush stdin up to now (by now I
  20. : mean some point in the code) and then read something so these extra \n's
  21. : won't clutter up the place.  I have tried seeks and all sorts of
  22. : trickery but to naught.
  23. : Thanks in advance
  24. : -Chris
  25.  
  26. The solution space for this problem is system dependent.  You'll likely
  27. need to play around with ioctl() or fcntl().  Essentially, you either
  28. need some kind of non-blocking read (see FIONBIO for ioctl() or FNDELAY
  29. for fcntl()) or some way of determining beforehand whether a read
  30. *would* block (and avoiding the read if so), such as FIONREAD for ioctl().
  31.  
  32. Larry
  33.