in reply to filter empty files

readdir returns file names, not paths, so -z could be failing to find the (right) file to check.

By the way, it would be faster to check -z second (since it requires an io call), and it would be better to avoid needless captures.

opendir(my $dh, $dir) or die("opendir: $!\n"); my @files = grep { ( !/\.(?:txt|prn|csv)\z/ && /$SrcPattern/ ) || -z } map "$dir/$_", readdir($dh);

Replies are listed 'Best First'.
Re^2: filter empty files
by sri1230 (Novice) on Sep 24, 2009 at 18:53 UTC
    thanks i forgot this part "readdir returns file names, not paths" Appreciate your help!