in reply to Optimising a search of several thousand files

Most optimization opportunities are in the inner loop. Exit the loop as quickly as possible for most cases.

split() and the array cleverness is a little bit slow, so this skips it most of the time:

while (<IN>) { $numlines++; # Remove for more speed next if not /^McDarren\t/; chomp(); my ($user,$level) = (split /\t/)[0,3]; next FILE if $level <= $currlevel; print "$file $user $level"; print "Processed $numlines lines in ". "$numfiles files (total files:$totalfiles)"; exit; }
It should work perfectly the first time! - toma