in reply to pattern string match while reading from the file

You can anchor the match to the beginning of the string:
if($line =~ /^$TEMP/) { # ^
Of course having item 90 will cause the same problem. For more details see: perlre, perlretut