in reply to How to tell if a Directory is Empty

Slight increase of Perlishness possible at line 5: No need for char classes; simply escape the dot and use the "+" quantifier (1 or more instances). IOW, make the regex unless ($file =~ /^\.+\z/) {

Further slight increase in Perlishness: Don't reinvent the wheel. Check out some of the File:... modules for the means to seek out UNsuspected no-file subdirs.

Nonetheless, ++ for developing your own approach which satisfies the specific spec you provide.

Replies are listed 'Best First'.
Re^2: How to tell if a Directory is Empty
by JavaFan (Canon) on Oct 29, 2011 at 00:26 UTC
    IOW, make the regex unless ($file =~ /^\.+\z/)
    Why would you change something that's correct, into something that isn't? Be aware that ... is a legal file name, and has not special meaning. And so is ..........

    I see nothing wrong the OPs regexp -- except that using a /[.]/ is a performance hit over /\./ in pre-5.10 versions of Perl. But I rather be slow and correct, than fast and incorrect.