why_bird has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I'm parsing a configuration file, so before doing the proecssing, I want to remove comments, which I take for granted are in the same style as Perl (i.e. one line comments starting with '#' which can occur after other text, which must be left intact)

Here is my code. It works fine unless it comes across '[]' in a comment in my config file (it works fine if the '[]' is outside a comment), when it throws this:
Unmatched [ in regex; marked by <-- HERE in m/ ...some text... [<-- HERE] ...some more text..

while (chomp(my $temp=<INPUT>)){ print Dumper $temp; if ($temp =~ /#/){ $temp =~ s/#$'//; } if ($temp =~ /^\s*$/){ next; } print "after regex:\n"; print Dumper $temp; print "end\n"; }

I'm a bit new with regexes so chances are I've missed something obvious---any ideas?

Those are my principles. If you don't like them I have others.
-- Groucho Marx