It would be interesting to see how much faster the win/dos "tree" utility is than the File::Find module (or any of its relatives on CPAN). I know that in unix, File::Find takes much longer than the standard "find" utility for a directory tree of any considerable size.

The only problem with the OP code is that you have to remember to run "tree" yourself -- and save its output in a specific file whose name is hard-coded in your perl script -- before running the script, so that you know your file list is up-to-date. But that's unnecessary -- just run "tree" inside the perl script (it'll still run just as fast):

my $music_path = ".\\music"; # probably should make this an absolute +path... open my $fh, "D:\\tree /f /a $music_path |" or die "cannot run tree on $music_path: $!"; while ( <$fh> ) { # everything else stays the same... }
(not tested -- I'm not a windows user)

Actually, it might also be interesting to see whether a win/dos port of the unix "find" utility is slower or faster than "tree"...


In reply to Re: Quick file search by graff
in thread Quick file search by sh1tn

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.