in reply to variable comparison

You could try something like:
if ($file !~ /$ext/) { ..do something if $file does not contain $ext.. }
I think this is what you are after....
Update: Sorry I didn't see the . in the .htm. That will break this solution as the . will resolve to 'any character'.