Bob Showalter wrote:
> Paul Kraus wrote:
> > WTF now its working with no changes to the program......
> > This is very frustrating.
> > Is perl some how looking at the way the directory was last
> > sorted in my
> > Ms window even though its pulling it from a UNIX server?
>
> Perl isn't doing anything but calling the OS's underlying readdir(2) call.
> You shouldn't make any assumptions about the order in which readdir()
> returns files. If you need them in some particular order, read them and then
> sort them.

Exactly. Moreover, you should never assume the order of anything
returned by an iterator like 'readdir' unless it is documented.

The nicest general solution I can think of is to use 'File::Find'
with your 'wanted' routine set to push $File::Find::name onto an
array @files. Then you can just do

  @files = sort { -M $A <=> -M $B} @files;

(People will then tell you to use Randalian Transform   ;-)
but then I will tell you to worry only if your code is too slow.)

Cheers,

Rob




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

Reply via email to