in reply to How do I determine whether a folder is empty?
sub is_empty { ! ( () = glob $_[0] . '/*' ); }
Note however that this approach employing glob will not include dot-files in the list used to determine whether the directory is empty - Thanks ++broquaint! If this is important, this code could be rewritten using the opendir, readdir and closedir sequence of commands, such as provided by perlplexer above.
Updated as per no_slogan's comments below.
perl -le 'print+unpack("N",pack("B32","00000000000000000000001001011011"))'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How do I determine whether a folder is empty?
by no_slogan (Deacon) on May 21, 2003 at 14:10 UTC |