"John W. Krahn" wrote:
>
> Sukrit K Mehra wrote:
> >
> > Hi listers,
>
> Hello,
>
> > While doing this -->
> >
> > @files = readdir(Favorites);
> >
> > i get an unsorted list in @files. What i desire is directories first and
> > then files. Using sort function would sort by ascii value and sort
> > by_name and such won't work too. Please suggest a solution.
>
> opendir DIR, $dir or die "Cannot open $dir: $!";
>
> my @files = sort { -d $b <=> -d $a or $a cmp $b }
> grep { !/^\.\.?$/ }
> readdir DIR;
Sorry, that should be:
opendir DIR, $dir or die "Cannot open $dir: $!";
my @files = sort { -d "$dir/$b" <=> -d "$dir/$a" or "$dir/$a" cmp
"$dir/$b" }
grep { !/^\.\.?$/ }
readdir DIR;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]