in reply to Stripping Comments

I don't see why you need the first regex.

Replies are listed 'Best First'.
Re^2: Stripping Comments
by betterworld (Curate) on Jun 10, 2007 at 00:54 UTC
    The problem with the first RE is that it removes the character before the hash mark. In your examples, it's always whitespace, so you didn't recognize it. You could replace the first regex with
    s/([^\\])#.*/$1/;
    Better yet, replace the first and second RE with the RE that varian provides. You'll need the third RE nonetheless.