in reply to Shorten script

There has been other good replies already, so I'll leave it with that. Except there is (at least) one thing that everyone seem to have overlooked.

The $ct variable is increased for every hit, or more interestingly, for each time @files is increased. So that can be replaced by

$ct -= @files; while (my $line = <F>) { ... } # Old code without $ct $ct += @files;
HTH,
ihb