File::Find will short-circuit, there is no need to change your code significantly. What you can do is to wrap the find calls in an evaluation block like below -
my @nod; eval { sub foo {die if (/^p/i); push @nod, $_} find (\&foo, "./"); }; print "$_\n" for @nod;
Note that I have replaced last in your example with die, which will cause the evaluation block to be short-circuited.

My directory contains the following files:
try.pl try3.pl try0.pl try4.pl try0.txt try9.pl try6.pl try7.pl try8.pl try10.pl try11.pl text.txt try12.pl try13.pl try14.pl try15.pl p01.pl p02.pl p03.pl p04.pl p05.pl p09.pl p10.pl p11.pl p12.pl try2.pl try1.pl webrobot.pl links.txt algorithm.pl mainfile.txt
I want the code to short circuit as soon as it sees a file beginning with letter 'p'. And the output of the code is just as expected -
try.pl try3.pl try0.pl try4.pl try0.txt try9.pl try6.pl try7.pl try8.pl try10.pl try11.pl text.txt try12.pl try13.pl try14.pl try15.pl

In reply to Re: File::Find exit by Roger
in thread 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.