Brian wrote:
Hello

Hello,

I would like to do a recursive search of directories and files, checking to see if a file contains a certain string.
<STDIN> will be a string containing whitespace(s).
As soon as I hit enter, I would like dummy.txt to be time stamped and again at termination.
I'm playing about with 9.85GB (2.57 million files).

If possible, full pathnames of the files containing the string to go to dummy.txt

I would like to see just how quickly PERL can complete a search, using Windows search facility I killed the incomplete search after leaving it to run for almost a day.

You could try this and see how it does:

#!/usr/bin/perl
use warnings;
use strict;
use File::Find;

open my $REPORT, '>', 'dummy.txt' or die "Cannot open 'dummy.txt' $!";
print $REPORT scalar localtime, "\n";

print STDERR 'Enter a string to search for: ';
chomp( my $string = <STDIN> );

find sub {
    return unless -f;
    open my $FH, '<:mmap', $_ or die "Cannot open '$_' $!";
    local $/;
    <$FH> =~ /\Q$string/ && print $REPORT "$File::Find::name\n" and return;
    }, '/path/to/search/from';

print $REPORT scalar localtime, "\n";

__END__



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to