home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7411 < prev    next >
Encoding:
Text File  |  1992-12-14  |  981 b   |  31 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!caen!malgudi.oar.net!chemabs!jon
  3. From: jon@cas.org (Jon Vander Hill)
  4. Subject: Re: C comment parser?
  5. In-Reply-To: mcook@fendahl.dev.cdx.mot.com's message of Sun, 13 Dec 1992 00:54:54 GMT
  6. Message-ID: <JON.92Dec14132300@cas.org>
  7. Sender: usenet@cas.org
  8. Organization: Chemical Abstracts Service, Columbus, Ohio
  9. References: <1268@galileo.rtn.ca.boeing.com> <mcook.724208094@fendahl.dev.cdx.mot.com>
  10. Date: Mon, 14 Dec 1992 18:23:00 GMT
  11. Lines: 18
  12.  
  13. >>>>> On Sun, 13 Dec 1992 00:54:54 GMT, mcook@fendahl.dev.cdx.mot.com (Michael Cook) said:
  14.  
  15. > You can do it with index():
  16.  
  17. >   $pos = 0;
  18. >   while (($pos = index($_, "/*", $pos)) >= 0)
  19. >   {
  20. >     $end = index($_, "*/", $pos + 2);
  21. >     $end >= 0 || die "unterminated comment";
  22. >     substr($_, $pos, $end - $pos + 2) = '';
  23.                                           ^^
  24. >   }
  25.  
  26. For what it's worth, I believe the ANSI C standard says that a comments
  27. turn into blanks.
  28.  
  29. Jon Vander Hill
  30. jon@cas.org
  31.