home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / perl / 4900 < prev    next >
Encoding:
Text File  |  1992-07-22  |  1.2 KB  |  36 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!stanford.edu!leland.Stanford.EDU!schemers
  3. From: schemers@leland.Stanford.EDU (Roland Schemers)
  4. Subject: Re: Process question...
  5. Message-ID: <1992Jul23.030645.16675@leland.Stanford.EDU>
  6. Sender: schemers@slapshot.stanford.eu
  7. Organization: Distributed Computing Group, Stanford University
  8. References: <1992Jul22.231637.23043@cs.unca.edu>
  9. Date: Thu, 23 Jul 92 03:06:45 GMT
  10. Lines: 24
  11.  
  12. In article <1992Jul22.231637.23043@cs.unca.edu> mcmahan@cs.unca.edu (Scott McMahan -- Genesis mailing list owner) writes:
  13. >
  14. >fork a process that will exec 'sort'
  15. >parent feeds sort a bunch of words, and reads sort's output for use later.
  16. >
  17.  
  18. #!/usr/local/bin/perl
  19. require 'open2.pl';
  20.  
  21. $pid = &open2("OUTPUT","INPUT","/usr/bin/sort");
  22.  
  23. @word=("just","another","perl","hack");
  24.  
  25. foreach(@word) {  print INPUT "$_\n"; }
  26.  
  27. close(INPUT);
  28.  
  29. while(<OUTPUT>) {  print "$_"; }
  30.  
  31. -- 
  32. Roland J. Schemers III              |            Networking Systems
  33. Systems Programmer                  |            168 Pine Hall   (415)-723-6740
  34. Distributed Computing Group         |            Stanford, CA 94305-4122
  35. Stanford University                 |            schemers@Slapshot.Stanford.EDU
  36.