"$Bill Luebkert" wrote:
>
> "Sidwell, Josh" wrote:
> >
> > I am trying to write a small script that will recursively search through a
> > directory tree (from some arbitrary point) and return all of the files it
> > finds that match an expression. I then want to grep the results for a
> > specific string in each of thos files and return the file name and line
> > number for each match.
> >
> > I am somewhat out of my depth in trying this. Any assistance would be
> > helpful.
> >
> > __Begin__
> > use strict;
> > use File::Find;
> > my @files = (''); # Array to hold the resulting
> > files
> > my $rootdir = 'c:/temp'; # Start here in this directory
> > find(/\.(html|htm|asp)$/i, ($rootdir)); # Examine the files
> > $#files = 999; # Set array size so that it is
> > not incremented each time
> > push ( @files, "$_" ); # Append the latest result
> > that matches to the array
> > print "@files\n"; # for debugging
> > purposes, to see what is returned
>
> Untested:
Tested:
use strict;
use File::Find;
my @files = (); # Array to hold the resulting files
my $rootdir = 'c:/temp'; # Start here in this directory
find (\&wanted, $rootdir); # Examine the files
foreach (@files) { # print list
print "$_\n";
}
exit 0;
sub wanted {
return if not /\.(html|htm|asp)$/i or not -f $_; # skip files not wanted and
non-plain files
push @files, $File::Find::name; # Append path (use $_ for just filename)
}
__END__
--
,-/- __ _ _ $Bill Luebkert ICQ=14439852
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // http://dbecoll.webjump.com/ (Free Perl site)
-/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users