in reply to glob() far slower than `dir`

Your readdir example can be improved by using list context and less system calls:

sub read_dir_list{ opendir(DIR, '.'); my @all_files = readdir DIR; closedir DIR; my @files = grep /^ABC.*/ @all_files; return @files; }
If you need to work with all the files condider sorting the file list by inodes. You'll use disk readahead instead of cache and disk seeks are minimized.

Replies are listed 'Best First'.
Re^2: glob() far slower than `dir`
by halley (Prior) on Feb 21, 2005 at 15:26 UTC
    The directory in question had 210,000 filenames in it. I was looking for about 500 names in that set. I realize that I could grep through a full set at once, but at the expense of about two~four megabytes of transient data being collected into memory. You're right, though; for benchmarking, I should consider adding that case.

    --
    [ e d @ h a l l e y . c c ]