home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacPerl 4.1.3 / t / io / pipe.t < prev    next >
Encoding:
Text File  |  1993-10-23  |  896 b   |  35 lines  |  [TEXT/MPS ]

  1. #!./perl
  2.  
  3. # $Header: pipe.t,v 4.0 91/03/20 01:51:02 lwall Locked $
  4.  
  5. $| = 1;
  6. print "1..8\n";
  7.  
  8. open(PIPE, "|-") || (exec 'tr', '[A-Z]', '[a-z]');
  9. print PIPE "OK 1\n";
  10. print PIPE "ok 2\n";
  11. close PIPE;
  12.  
  13. if (open(PIPE, "-|")) {
  14.     while(<PIPE>) {
  15.     s/^not //;
  16.     print;
  17.     }
  18. }
  19. else {
  20.     print STDOUT "not ok 3\n";
  21.     exec 'echo', 'not ok 4';
  22. }
  23.  
  24. pipe(READER,WRITER) || die "Can't open pipe";
  25.  
  26. if ($pid = fork) {
  27.     close WRITER;
  28.     while(<READER>) {
  29.     s/^not //;
  30.     y/A-Z/a-z/;
  31.     print;
  32.     }
  33. }
  34. else {
  35.     die "Couldn't