home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / question / 9625 < prev    next >
Encoding:
Internet Message Format  |  1992-07-30  |  818 b 

  1. Path: sparky!uunet!usc!nic!netlabs!lwall
  2. From: lwall@netlabs.com (Larry Wall)
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: Good way to strip K&R style comments
  5. Message-ID: <1992Jul31.055006.22125@netlabs.com>
  6. Date: 31 Jul 92 05:50:06 GMT
  7. References: <1251@bridge2.NSD.3Com.COM>
  8. Sender: news@netlabs.com
  9. Organization: NetLabs, Inc.
  10. Lines: 12
  11. Nntp-Posting-Host: scalpel.netlabs.com
  12.  
  13. In article <1251@bridge2.NSD.3Com.COM> div@NAD.3Com.COM writes:
  14. : 1.The shortest perl solution was from  guru and was as follows
  15. : perl -e 'undef($/);$_=<>;s/\/\*[^\000]*\*\///g;print'   filename
  16.  
  17. That's actually incorrect for any program with more than one comment--it'll
  18. eat everything between the first and last comment.  The following will
  19. do much better:
  20.  
  21.     perl -e '$/ = "*/"; while (<>) { $_ = $` if m!/\*!; print; }'
  22.  
  23. Larry
  24.