home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / question / 10519 < prev    next >
Encoding:
Internet Message Format  |  1992-08-30  |  1.7 KB

  1. Path: sparky!uunet!paladin.american.edu!darwin.sura.net!wupost!cs.utexas.edu!uwm.edu!ogicse!reed!romulus!merlyn
  2. From: merlyn@romulus.reed.edu (Randal L. Schwartz)
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: AWK Iteration
  5. Message-ID: <MERLYN.92Aug29134120@romulus.reed.edu>
  6. Date: 29 Aug 92 20:41:24 GMT
  7. Article-I.D.: romulus.MERLYN.92Aug29134120
  8. References: <1992Aug28.183452.2245@midway.uchicago.edu>
  9. Sender: news@reed.edu (USENET News System)
  10. Organization: Reed College
  11. Lines: 27
  12. In-Reply-To: a-douglas@uchicago.edu's message of 28 Aug 92 18:34:52 GMT
  13.  
  14. In article <1992Aug28.183452.2245@midway.uchicago.edu> a-douglas@uchicago.edu (Allen Douglas) writes:
  15.    The logic is: 
  16.  
  17.    Read in to beginning of first break point (case)-(this output will be discarded)
  18.    Start reading the first case until beginning of next case and send text of case to temporary file .
  19.           Process commands on temp file, output to results file(s.)
  20.    Read in text of the next case, until the begining the next+1 case.    (replacing the previous output)
  21.  
  22.    The cases (as in legal case) have delimeters of "of 38 CASES" 
  23.  
  24.  
  25. In Perl, this would be:
  26.  
  27. perl -pe 'open(STDOUT,"|some_command >result.".++$i),$_="",next if /of 38 CASES/' \
  28.     <yoursourcefile >headertext
  29.  
  30. "headertext" will contain the stuff before the first "of 38 CASES".
  31. "result.1","result.2"... will contain the results of running "some_command"
  32. over each segment between "of 38 CASES".
  33.  
  34. Too easy with Perl.
  35.  
  36. print "Just another Perl hacker,"
  37. --
  38. Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
  39. merlyn@reed.edu (guest account) merlyn@ora.com (better for permanent record)
  40. cute quote: "Welcome to Portland, Oregon -- home of the California Raisins!"
  41.