Looking for a Windows based grep utility for Windows 95 
Author Message
 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) 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!

-Derek



Mon, 12 Apr 1999 03:00:00 GMT  
 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)



Mon, 12 Apr 1999 03:00:00 GMT  
 Looking for a Windows based grep utility for Windows 95

<emailed and posted>

You can find UNIX utilities (including grep) for Win95/NT at:

ftp.cygnus.com/pub/sac/win32

Of course, you could also write your own grep in perl, which could be
faster depending on how you write it.  A colleague of mine wrote a
recursive search script which shells out to egrep for the actual
search, which turned out to be twice as slow as a recursive search I
wrote completely in perl.  The 'hard' part is building in all the
functionality of the original, if you need it.

-Kevin


Quote:
>I am looking to implement a Perl script that will search a directory
>(or many directories) 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!

>-Derek



Mon, 12 Apr 1999 03:00:00 GMT  
 Looking for a Windows based grep utility for Windows 95


Quote:
>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);
>}

Might also want to mention that adding the 'o' modifier after the
/$pattern/ might help keep things speedy:

                if (/$pattern/o) {...}

That way, $pattern only gets compiled once.

-Kevin



Tue, 13 Apr 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Relational database for Windows/Windows 95/NT

2. Installing Perl on Windows 95 or Windows 98

3. Where can I get Perl for Windows NT or Windows 95

4. Looking for sendmail.exe app for Windows 95

5. Looking for Sendmail for Windows 95

6. Q: Module installion on Windows 95

7. msqlperl for windows 95

8. dbm problem on windows 95

9. Perl and DB_File on Windows 95

10. Unable to install libwww-perl on Windows '95 platform

11. Problem installing libwww-perl on Windows '95 platform

12. Looking for Perl-based NNTP passthrough utility.

 

 
Powered by phpBB® Forum Software