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