Solved

identifying and separating directories from files

Posted on 2001-07-03
4
166 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

832 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