in reply to File handles in regular expressions

Did you forget to chomp $comp2? Lines read from file handles can contain newline characters (usually \n).
Sorry if my advice was wrong.