in reply to variable comparison

As mentioned you can use either index or a regex. If you are specifically looking to check a file extension, you'll want to ensure that the extension is at the end of the string. (That is, you don't want "file.htm.txt" to show up as a .htm file.)
The Regex way: Corrected, as I too fell for the .
$ext="\.htm"; if($file=~ /$ext$/){ #Extension is at end of file # The final $ matches the end of the string. }
The edit way:
if((index ($filename, $ext) + 1 + length($ext))==length($filename)){ #Extension was at end of $filename #Untested, I might be off by one }