Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: How to tell if a Directory is Empty

by ciderpunx (Vicar)
on Nov 11, 2011 at 23:38 UTC ( [id://937693]=note: print w/replies, xml ) Need Help??


in reply to Re: How to tell if a Directory is Empty
in thread How to tell if a Directory is Empty

return $count - 2; #maybe not the best way of removing . and . +.
Perhaps use grep for that?
sub isEmpty3 { return undef unless -d $_[0]; opendir my $dh, $_[0] or die $!; my $count = grep { ! /^\.{1,2}/ } readdir $dh; # strips out . and +.. return $count; }


Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://937693]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2025-12-12 14:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (92 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.