I should read posts more carefuly before answering, your use of File::Find was totaly unnoticed by me. You can't pass return values through the call of find, use a global variable instead, as you originaly did. Here a slightly modified version, that searches use lines in .pl files.

use File::Find; my($ct, @data) = (0,()); sub fetcher { if( $_ =~ /\.pl?$/) { my $name = $File::Find::name; open ( F, $name ) or die "$!: $name\n"; my @lines = <F>; close(F); my @matches = grep(/^use/, @lines); push(@data, @matches); $ct += scalar(@matches); } } find( {wanted => \&fetcher, no_chdir => 1, }, "." ); print "\n\nTotal Count = $ct\n\n"; print @data; __END__ Total Count = 8 use strict; use WWW::Search::Tv::German::Tvtoday 1.02; use File::Find; use File::Basename; use HTML::TokeParser; use LWP::Simple; use LWP::Simple; use Net::POP3;
Notice that I slurp the file and use grep to find the matches, I think it looks more like perl this way.

And by the way: I would realy like to know, for what purpose you wrote this code, as it seems to me, if you had posted that, someone could come up with a more proper solution, just a humble guess...

Oh, and as a further note: proper, read: consistent, indenting of code is most welcome here ;-)

regards,
tomte


Hlade's Law:

If you have a difficult task, give it to a lazy person --
they will find an easier way to do it.


In reply to Re: Re: Re: Show count before data output by Tomte
in thread Show count before data output 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.