in reply to Re: Matching C-Style comments
in thread Matching C-Style comments

Well, your regex isn't enough, because while it matches /*, it doesn't check whether that occurs inside a string or not - and when it's inside a string, it's not the start of the comment. I won't repeat the regex here, you can find it in the hip owls book, and there are pointers to it already posted.

As for your second question, it's not just the first line that's echoed, it's the second line too, there's a /* after the MATCH! The reason is your use of -p, which means that $_ is printed for each line of input processed. Regardless of any print statements in the program. You probably want to use -n instead.

-- Abigail