Solved

identifying and separating directories from files

Posted on 2001-07-03
4
165 Views
Last Modified: 2013-12-25
I have the contents of a directory in an array (@contents).

I want to push all files present in @contents to @files and all directories present in @contents to @dir

Yelp

Anant
0
Comment
Question by:anant99
4 Comments
 
LVL 3

Accepted Solution

by:
monas earned 50 total points
ID: 6248160
if this is perl, then

push @files,map {-f $_? $_: ()} @contents;
push @dir,map {-d $_? $_: ()} @contents;
0
 
LVL 5

Expert Comment

by:marecs
ID: 6248201
push @files, grep {-f } @contents;
push @dir, grep {-d } @contents;
0
 
LVL 1

Author Comment

by:anant99
ID: 6251773
i am testing them out. i shall accept one of them soon.

Anant
0
 
LVL 2

Expert Comment

by:shirjeel
ID: 6260719
hey man use this code
$i = 0;
foreach $file((@contents)
{
if(-e $file)
{
@dir[$i] = $file;
$i++;
}
}

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now