in reply to How to tell if a Directory is Empty

You can grep the list of files for anything other than '.' and '..', and since any results from grep will equal true:

opendir my $dir, $dirname or die $!; if( grep ! /^\.\.?$/, readdir $dir ){ print 'stuff in here'; }

Replies are listed 'Best First'.
Re^2: How to tell if a Directory is Empty
by jwkrahn (Abbot) on Oct 29, 2011 at 02:49 UTC

    You are using the $ anchor instead of the \z anchor which means that the directory will be considered empty if there is a valid file named ".\n" or "..\n".