[Omaha.pm] Help with File::Find

Mike Hostetler hostetlerm at gmail.com
Wed Nov 5 13:50:41 PST 2008


It's probably been years since I've done anything more than a 5 line Perl
script, or just did minor fixes on someone else's code.  But we have a log
scraper that, uh, well, sucks and I'm the only one brave (or stupid) enough
to change it.

One of the things that I want to do is to grab the latest file under a
directory with a pattern.    And, since I want it to find the file
recursively, I know I need to use File::Find. The fl

sub logFinder {
  my $proc="pat"
  my @files=();

  sub wanted {
     /^$proc.*/s
       && push(@files,$File::File::name);
   }

  find(\&wanted ,$logdir);

<yadda-yadda>

My "wanted" will give me a list of files the first time I access logFinder,
but the next time I run it, the values in @files are not refreshed.

So that's what I got.  I know someone here can do better . . .

-- 
Mike Hostetler
http://mike.hostetlerhome.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/omaha-pm/attachments/20081105/de0df8c4/attachment.html>


More information about the Omaha-pm mailing list