home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / perl / 7114 < prev    next >
Encoding:
Text File  |  1992-11-23  |  1.2 KB  |  47 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!cs.utexas.edu!asuvax!ncar!tres
  3. From: tres@rap.ucar.edu (Tres Hofmeister)
  4. Subject: chat2.pl Question
  5. Message-ID: <1992Nov23.215146.2558@ncar.ucar.edu>
  6. Keywords: &chat'expect, $*, $/
  7. Sender: news@ncar.ucar.edu (USENET Maintenance)
  8. Organization: NCAR, Research Application Program
  9. Distribution: na
  10. Date: Mon, 23 Nov 1992 21:51:46 GMT
  11. Lines: 34
  12.  
  13.  
  14.     I'm a bit confused about the behavior of &chat'expect from
  15. the chat2.pl library.  Why is it that, in a simple script I can use:
  16.  
  17. $* = 1;
  18. $/ = undef;
  19. while (<>) {
  20.     /(.|\n)*/ && print $&;
  21. }
  22.  
  23.     ...and get paragraph output, but when using chat2.pl:
  24.  
  25. $* = 1;
  26. $/ = undef;
  27. &chat'expect($handle, $secs, '(.|\n)*', '"$&"');
  28.  
  29.     ...I don't?  In fact, I get nothing, even when there is
  30. stuff available for reading.  I find that I have to use something
  31. like this:
  32.  
  33. while ((&chat'select($timeout, $handle))[0] eq $handle) {
  34.     print &chat'expect($handle, $secs, '(.*)\n', '"$1\n"');
  35. }
  36.  
  37.     ...and build up the output line by line.  Why is this?
  38. The version of the library is: V2.01.alpha.7 91/06/16, if it makes
  39. a difference.
  40.  
  41.     Thanks in advance.  Any assistance or suggestion is
  42. appreciated, as are appropriate FM references. :-)
  43.  
  44. --
  45. Tres Hofmeister
  46. tres@ncar.ucar.edu
  47.