in reply to Tutorial on File::Find even more basic than "Beginners Guide"

Would this help? It's Windowsish, but'll still work. Of course, you could probably use real grep, too.


use warnings; use strict; use File::Find; open (OUT, ">C://strings.txt"); my $search_string = 'http'; find( \&grep, "C:\\Program Files\\whatever" ); sub grep { my $file = $File::Find::name; if ( -f $file && -r _ ) { open( my $fh, "<", $file ) or return; while ( my $rec = <$fh> ) { print OUT "$rec" #in $_\n" if $rec =~ /$search_string/; } } }

Replies are listed 'Best First'.
Re^2: Tutorial on File::Find even more basic than "Beginners Guide"
by ww (Archbishop) on Jan 20, 2005 at 23:11 UTC
    McMahon:

    I guess Joost's critique was fairer than I realized. If I understand your code correctly, this addresses the flip-side of my problem, but I will now compare your sub with docs, in the strong suspicion that the example WILL help me understand said docs/tutorials/whatever.

    Thank You!