
Looking for a Windows based grep utility for Windows 95
: I am looking to implement a Perl script that will search a directory
: (or many directories)
This part is left as an exercise for the reader ;-)
: for certain text and then return a listing of
: the files containing the text (for use on a web page, I am running the
: Perl 32 port). I know that grep can be used to accomplish this in
: UNIX but I am using a Windows http server. I cannot seem to find a
: windows version that be called from the Perl script. Anyone have any
: suggestions or found a program that fits the bill? Thanks for any help
: in advance!
step 1) man perlre
step 2) read it for a while ;-)
step 3) bang out:
----------------
#!/usr/bin/perl -w
# ^^ ALWAYS enable compiler warnings
# add argument checking here...
$pattern=shift; # the first argument is the search regex
while ($fname = shift) { # search each file named on command line
open(FILE, $fname) || die "could not open '$fname' for input $!";
while (<FILE>) {
if (/$pattern/) {
print "$fname\n"; # print the filename
last; # go do next file
}
}
close(FILE);
Quote:
}
----------------
--
Tad McClellan, Logistics Specialist (IETMs and SGML guy)