Paul Kraus wrote:
> 
> I have a program that would read a directory and then do some renaming.
> Up until recently it always seem to read by oldest file first to newest.
> Which is great because my renaming involves incrementing a counter and
> placing that count in each file. So if the order was changed the program
> will break. Which it did.
> 
> So two questions why is it reading the directories different now?

Files are not stored on the file system in any predefined order.  If
they appear to be in some order then that is just a coincidence.  If you
want the file names in a certain order then you will have to sort them
yourself.


> How can I have it read the directory with oldest file first.

my $dir = '//sco1/pm6/reports';

opendir DH, $dir or die "Can not open $dir: $!";

my @files = map $_->[0],
            sort { $b->[1] <=> $a->[1] }
            map [ $_, -M "$dir/$_" ],
            grep /^Sj/,
            readdir DH;

closedir DH;



John
-- 
use Perl;
program
fulfillment

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

Reply via email to