common error... i do it all the time. There are different comparators for strings and numberical data. "==" is numerical and you want to compare strings so you should use eq.
ie..

$tmpstr=substr($temp_file,-4,4);
if ($tmpstr eq ".htm")
{
print "True: $temp_file ($tmpstr)<BR>\n";
}

the other operators like this are
Numerical - String - Use
== - eq - is equal to
<> - ne - is not equal to
> - ge - is greater than
< - le - is less than

that is the basic ones there are others like ++ and -- but you wouldnt need to use them now.