Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: How do I determine whether a folder is empty?

by crouchingpenguin (Priest)
on May 21, 2003 at 16:28 UTC ( [id://259783]=note: print w/replies, xml ) Need Help??


in reply to Re: How do I determine whether a folder is empty?
in thread How do I determine whether a folder is empty?

sorry, couldn't resist =]

#!/usr/bin/perl use strict; use warnings; sub isEmpty { opendir(DIR,shift) or die $!; my @files = grep { !m/\A\.{1,2}\Z/} readdir(DIR); closedir(DIR); @files ? 0 : 1; } print isEmpty('./dir') ? "empty\n" : "not empty\n";

cp
----
"Never be afraid to try something new. Remember, amateurs built the ark. Professionals built the Titanic."

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-23 18:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found