Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

identifying and separating directories from files

Posted on 2001-07-03
4
Medium Priority
?
174 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 3

Accepted Solution

by:
monas earned 150 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

647 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