[EMAIL PROTECTED] wrote:

> Hello, All:
> 
> When using...
> 
> while ($x = readdir(DH)) {
> # What came before $x?
> # What will come after $x?
> }
> 
> How can I look at the next item in the directory?
> 

i don't really know what you mean by before or after. directoris are not 
really in any order. they are organized by the OS. you often see order 
because if you use the 'ls' or 'dir'(DOS) command, they sort the listing 
for you. you could sort the listing in any order you want, put them in an 
array and then exam them one by one:

#!/usr/bin/perl -w
use strict;

open(DIR,'dir') || die $!;
#-- like the order of ls
foreach my $dir (sort {lc($b) cmp lc($a)} readdir(DIR)){
        print "$dir\n";
}
closedir(DIR);

or by size:

foreach my $dir (sort {-s "dir/$b" <=> -s "dir/$a"} readdir(DIR)){
        print "$dir\n";
}

... etc

instead of print, you can capture them in an array and then exam them in 
that order you want.

david

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to