I hesitate asking this because it seems like it must be rudementary, however I read the perldoc, camel, and searched here and still have not found the answer. If I've missed in my searching please be gentle. I need a way to exit out of a file find. something like (this does not do what I want):

sub foo {last if (/^d/i); push @nod, $_} find (\&foo, "/somedir");

The above code pushes all filenames in the /somedir directory except the files beginning with 'd|D'. What I need is just the files that come before the files beginning with 'd|D'.

TIA

Update:

I tried to give an example that simplified what I need, I guess I simplified too much. I'll try to elaborate.

The process I'm creating needs to iterate through a given directory and any sub directories recursivley. As it goes through these files it needs to open each regular file it finds and evaluate the contents of the file to determine the file type (ascii data, binary data, xml, html, empty, etc) based on several specific rules I need to abandon the find and reset, then move to the next iteration of the outer loop (not seen in above example). The more I think about this, and the more I read from this thread, the more I believe that File::Find may not be the best mechanism for recursivley iterating through the files(in this case). But I'm not sure of how to do it any other way without risking the pitfalls of recursion.
If anyone has suggestions I'd be greatful.

Thanks Again!


In reply to File::Find exit by sweetblood

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.