Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Tutorial on File::Find even more basic than "Beginners Guide," [id://217166]

by McMahon (Chaplain)
on Jan 20, 2005 at 23:04 UTC ( [id://423823]=note: print w/replies, xml ) Need Help??


in reply to Tutorial on File::Find even more basic than "Beginners Guide," [id://217166]

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/; } } }
  • Comment on Re: Tutorial on File::Find even more basic than "Beginners Guide," [id://217166]
  • Download Code

Replies are listed 'Best First'.
Re^2: Tutorial on File::Find even more basic than "Beginners Guide," [id://217166]
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!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://423823]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-19 16:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found