http://qs321.pair.com?node_id=707262


in reply to Re: greater efficiency required (ls, glob, or readdir?)
in thread greater efficiency required (ls, glob, or readdir?)

what about skipping the directory entries?

my $dir = '/Path/to/a/data/directory'; opendir my $DH, $dir or die "Cannot open '$dir' $!"; my %hash; while ( my $file = readdir $DH ) { next if $file =~ /~$/; next if -d "$dir/$file"; # should also skip +'.' and '..' entries # read and process file }

update: fix path issue "$dir/$file"