Solved

identifying and separating directories from files

Posted on 2001-07-03
4
164 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
Comment Utility
if this is perl, then

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

Expert Comment

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

Author Comment

by:anant99
Comment Utility
i am testing them out. i shall accept one of them soon.

Anant
0
 
LVL 2

Expert Comment

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

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Help with my python script 6 145
Problem to see relevant event 12 55
Python error - Need Help 12 82
Convert OverPunch 25 57
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…
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…
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 …
The viewer will learn how to dynamically set the form action using jQuery.

744 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

13 Experts available now in Live!

Get 1:1 Help Now