in reply to avoiding a particular character or set of characters

You can adapt the following to your needs (it does not cover all the ways one can put comments in code):
my $inComment = 0; while(<>) { next if $inComment; s|//.*$||; # remove // comments s|/\*.*?\*/||; # remove /*..*/ comments s|^.*\*/|| and $inComment = 0; s|/\*.*$|| and $inComment = 1; # do your pattern matching on $_ here }
-imran