home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5489 < prev    next >
Encoding:
Internet Message Format  |  1992-08-25  |  1.1 KB

  1. Path: sparky!uunet!wupost!usc!news!netlabs!lwall
  2. From: lwall@netlabs.com (Larry Wall)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: system & exec questions
  5. Message-ID: <1992Aug25.225237.11362@netlabs.com>
  6. Date: 25 Aug 92 22:52:37 GMT
  7. References: <1992Aug20.234826.28608@csus.edu>
  8. Sender: news@netlabs.com
  9. Organization: NetLabs, Inc.
  10. Lines: 20
  11. Nntp-Posting-Host: scalpel.netlabs.com
  12.  
  13. In article <1992Aug20.234826.28608@csus.edu> eburk@sfsuvax1.sfsu.edu (Eli Burk) writes:
  14. : I am having some difficulty understanding how to use perl
  15. : system & exec functions. As an example if I have @list
  16. : and I want to send this out to my system (unix) what is
  17. : the best wa? As an example I want to use unix "pr"
  18. : the following is from memory - but it shows the basic idea...
  19. : csh script fragment (cal 9 1992; cal 10 1992) | pr -t -2
  20. : How do I acomplish the same thing in perl? If I pass the 
  21. : "cal"s to @list how can I then pipe @list to "pr"?
  22.  
  23. That is a bit underspecified, but try something like this:
  24.  
  25.     open(INPUT, "cal 9 1992; cal 10 1992|");
  26.     open(OUTPUT, "| pr -t -2");
  27.     @list = <INPUT>;
  28.     print OUTPUT @list;
  29.     close INPUT;
  30.     close OUTPUT;
  31.  
  32. Larry
  33.