Link to home
Start Free TrialLog in
Avatar of anant99
anant99

asked on

identifying and separating directories from files

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
ASKER CERTIFIED SOLUTION
Avatar of monas
monas
Flag of Lithuania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of marecs
marecs

push @files, grep {-f } @contents;
push @dir, grep {-d } @contents;
Avatar of anant99

ASKER

i am testing them out. i shall accept one of them soon.

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