Here's how I get all the files of a directory.  I'm sure there are a hundred
ways of doing it:

my @files;
opendir(DIR,$dir) || die $!;
#Get only files
while (defined(my $file = readdir DIR))
{
        #filter out dot directories and zero-size files (i.e. regular directories)
        push @files, $file if $file ne '.' and $file ne '..' and  !-z "$dir/$file";
}
closedir(DIR);

inside the while loop:
push each $file that is NOT a 'dot' directory and is NOT a zero-sized file
(i.e. a directory) to the array @files.



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Barlow, Neil
Sent: Wednesday, August 28, 2002 9:49 AM
To: [EMAIL PROTECTED]
Subject: Disregarding Folders In A Directory


Hi all,

I am a newbie to perl...

I am using the opendir command to open up a directory and do some processing
of the files contained within the directory.

But the problem is that there are various folders which are being added into
the directory. Is there a way to disregard the folders and just deal with te
files that are in the directory?

Thankyou for you assistance,

Regards,
Neil Barlow
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to