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

Re: Bad Regex

by RollyGuy (Chaplain)
on Jun 23, 2003 at 18:02 UTC ( #268254=note: print w/replies, xml ) Need Help??


in reply to Bad Regex

You should try Regexp::Common::comment for common regexes that match comments. It will probably be better than rolling your own.

As for the line count, you can simply keep a counter as you go through the lines of the file. So, set a variable outside of your foreach loop and increment each time to get the new line number.

Replies are listed 'Best First'.
Re: Bad Regex
by Abigail-II (Bishop) on Jun 24, 2003 at 02:39 UTC
    Eh, no, not really. The OP seems to want to find comments inside a program. Regexp::Common just has regular expressions for comments - for Perl comments, it would find any text starting with a pound sign, and ending with the next newline. It's not a full language parser, something you really need if you want to find comments inside Perl programs. You might be able to get away skipping over anything inside quotes in a C or Java program, but that isn't true for Perl. You really need to parse (or be Damian).

    Abigail

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2022-08-15 04:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?