in reply to Re^2: CMD says files is closed when It should be open
in thread CMD says files is closed when It should be open

choroba has a good eye(!), catching the '.' (current directory) entry, and then recommending using the '-f' file test operator.

If you're only processing htm(l) files, then here's another option that you can place immediately below the while line:

next unless $secfile =~ /\.html?$/;

This will only allow the htm(l) file names through.