in reply to Capture filename

while (defined(my $fn = readdir($dh))) { ... }

readdir