[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Omaha.pm] Help with File::Find



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/