home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / perl / 5769 < prev    next >
Encoding:
Text File  |  1992-09-08  |  1.7 KB  |  47 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!eff!news.oc.com!convex!tchrist
  3. From: Tom Christiansen <tchrist@convex.COM>
  4. Subject: Re: Prompting for input
  5. Originator: tchrist@pixel.convex.com
  6. Sender: usenet@news.eng.convex.com (news access account)
  7. Message-ID: <1992Sep8.174308.17093@news.eng.convex.com>
  8. Date: Tue, 8 Sep 1992 17:43:08 GMT
  9. Reply-To: tchrist@convex.COM (Tom Christiansen)
  10. References: <1992Sep8.141620.12312@sbil.co.uk>
  11. Nntp-Posting-Host: pixel.convex.com
  12. Organization: Convex Computer Corporation, Colorado Springs, CO
  13. X-Disclaimer: This message was written by a user at CONVEX Computer
  14.               Corp. The opinions expressed are those of the user and
  15.               not necessarily those of CONVEX.
  16. Lines: 29
  17.  
  18. From the keyboard of jim@spitws117.sbil.co.uk:
  19. :foreach $file (@ARGV)
  20. :{
  21. :    print "'$command $file'";
  22. :    $ans = getc;
  23. :    exit if $ans eq "q";
  24. :    next COMMAND if $ans eq "n";
  25. :    
  26. :    system $command, $file;
  27. :}
  28.  
  29. :This works fine as long as you want to either execute everything or
  30. :quit part way through, but if you type "n\n" to skip an instance, it
  31. :skips that instance alright but executes the next one without a
  32. :pause.  It appears to me that there must be something left on STDIN
  33. :as a result of entering the string "n\n", but I can't find anything
  34. :in the Camel book about such an occurrence, or how to "suck"
  35. :everything off STDIN without sending an EOF.  
  36.  
  37. :Does anybody have any idea what's going on and how to fix it?
  38.  
  39. It's just your friend getc().  Use <STDIN> instead.
  40.  
  41. --tom
  42. -- 
  43.     Tom Christiansen      tchrist@convex.com      convex!tchrist
  44.  
  45.  
  46.         Disco is to music what Etch-A-Sketch is to art.
  47.