Spent five hours trying to find a workaround to this, so now I'm asking the experts.

When I use File::Find it correctly (to my mind) works as expected. Starting from a root folder, it lists all the files in that folder, and THEN dives into each directory to get the results within that.

But when using PHP Recursive RII, it lists the dot files first (such as .htaccess), then goes alphabetical through directories (affiliate, cgi-bin, poppa ...) and then lists the remainder files in the root ar bottom, followed by "_folder" of the root at the bottom! (It looks like it is following the ASCII table, ie dot, a - z, and then "_")

What's also strange is that one script returns 7533 directories / files, and the other 7536. I can't trace the missing files as both are returned in a different format. I tried sort to get them into a natural order, but again both created different text files!

I need both to create a "tree", such that root contains 10 files, and 10 folders, it displays 10 files, and then recurse into the folders. As I say, find::file does this, but the other might need some "flags" I cannot find on 'net

I have also tried Find::File::Rule - which is supposed to be easier - but can only get it to list all directories, or all folders. Not as per the tree format of Find::File !!

find(\&procFiles, "$dir"); open ($fh, ">", "siteFull.txt"); print $fh @file; close ($fh); print "all done"; sub procFiles{ if (-d){ push(@file, "--> DIRECTORY ".$File::Find::name."\n"); } if (-f){ push (@file, $File::Find::name."\n"); } }

The RII may need -or() or piped to second RII. (Appreciate this is PHP, not PERL, but maybe someone has a few pointers


In reply to File:: Find and PHP RII variation by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.