Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Best tool for my requirements?

by TedPride (Priest)
on May 25, 2006 at 08:22 UTC ( [id://551541]=note: print w/replies, xml ) Need Help??


in reply to Best tool for my requirements?

A very basic example showing that Perl can theoretically do this quite easily. I don't know what other comment styles you want removed, however, so I imagine this will need some tweaking.
$_ = join '', <DATA>; # Remove comments that don't start the line s/^.+\/\*.*?\*\//-/mg; # Remove comments spanning multiple lines s/\/\*(.*?)\*\/.*?\/\*\1\*\///sg; # Remove ignored characters s/[{} ]+//g; map { $c++ if $_; } split /\n/, $_; print "$c lines of code."; __DATA__ /* LM-2006-01 */ multi-line comment /* LM-2006-01 */ for (i = 0; i < 10; i++) { int my var; /* LM-2006-01 */ } /* LM-2006-01 */ another multi-line comment /* LM-2006-01 */

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-19 21:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found