Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: how do I print content of a cpp file without cpp comments?

by davorg (Chancellor)
on Sep 19, 2006 at 13:57 UTC ( #573725=note: print w/replies, xml ) Need Help??


in reply to Re: how do I print content of a cpp file without cpp comments?
in thread how do I print content of a cpp file without cpp comments?

It's been a while since I've written much C or C++, but doesn't your code have a slight problem when the comment character sequences appear in quoted strings?

Which (along with jarich's bug) just goes to illustrate the problems of trying to parse complex data using regular expressions. You'll almost certainly fall over subtle edge cases unless you use a real parser.

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

  • Comment on Re^2: how do I print content of a cpp file without cpp comments?

Replies are listed 'Best First'.
Re^3: how do I print content of a cpp file without cpp comments?
by hgolden (Pilgrim) on Sep 19, 2006 at 14:10 UTC
    Yep, I concede. File::Comments it is. This is what happens when you learn Perl without going through C first, and forget to always check CPAN :)

    Hays

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://573725]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2023-01-28 22:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?