in reply to Regex error when [] occurs in file..

$temp =~ s/#$'//; I'm not even sure what you want that to do, but it constructs a regex out of # followed by whatever was followed by the previous match. Any regex special characters in that generated string will be interpreted as regex directives.

You probably want something like:

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