in reply to Long list is long

kcott already provided a nice clean Perl solution. If his solution is running too slowly, please post a reply with your new code, along with system profiling output, just in case we can spot any booboos you might have made in implementing his suggestions.

Given you have "2064 files (up to a couple hundred MB)", it would not surprise if you've hit a chronic thrashing problem. If so, I can see three options you might try:

Alternative suggestions welcome.