home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5512 < prev    next >
Encoding:
Text File  |  1992-08-26  |  1.2 KB  |  47 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!ftpbox!mothost!merlin.dev.cdx.mot.com!fendahl.dev.cdx.mot.com!mcook
  3. From: mcook@fendahl.dev.cdx.mot.com (Michael Cook)
  4. Subject: Re: Simultaneous processes
  5. Message-ID: <mcook.714854903@fendahl.dev.cdx.mot.com>
  6. Sender: news@merlin.dev.cdx.mot.com (USENET News System)
  7. Nntp-Posting-Host: fendahl.dev.cdx.mot.com
  8. Organization: Motorola Codex, Canton, Massachusetts
  9. References: <root.714838821@merlin>
  10. Date: Wed, 26 Aug 1992 18:48:23 GMT
  11. Lines: 34
  12.  
  13. peter@merlin.acadiau.ca (Peter Steele) writes:
  14.  
  15. >How does one set up simultaneous processes in perl? For example,
  16. >how would I translate the following into perl:
  17.  
  18. >    #!/bin/sh
  19.  
  20. >    ls -la > d1 &
  21. >    ls -la > d2 &
  22. >    ls -la > d3 &
  23. >    wait
  24. >    cat d1 d2 d3 > d4
  25.  
  26. ...
  27.  
  28. >            wait for all processes to complete and combine output;
  29.  
  30. It would probably be enough to wait for them in the order they were started.
  31. For example, here's the logic from a script I use run parallel rsh's:
  32.  
  33. foreach $host (@host)
  34. {
  35.     open($host, "rsh $host $command |") || die "popen";
  36. }
  37. foreach $host (@host)
  38. {
  39.     while (<$host>)
  40.     {
  41.         &do_something_with($_);
  42.     }
  43.     close($host);
  44. }
  45.  
  46. Michael.
  47.