Hi again, Here is the problem: I want to search for a string in a directory. I copy-pasted whole program as below: What program does is, . . simply nothing. It returns nothing. Can anybody see why? Can it be related to a problem with the file test? Best regards, Melis #!/usr/local/bin/perl -w -I/apps1/local/lib/perl5/site_perl/5.8.3
use File::Find; $TOP_DIR="../tftpboot"; $query = "module 3"; find(sub { return if -d; open(FILE,"$File::Find::name"); while(<FILE>) { my $line = $_; chomp($line); $count = $count=1; next unless ($line =~ /$query/); $string.= "line $count: $line\n"; } if($string ne ''){ print "$string\n" } $count = 0; close(FILE); }, $TOP_DIR); --- zentara <[EMAIL PROTECTED]> wrote: > On Wed, 9 Jun 2004 06:13:39 -0700 (PDT), > [EMAIL PROTECTED] (Melis > Mutlu) wrote: > > >Hi, > > > >My problem is with File::Find module. I do not > exactly > >understand how it works. On the website it says > that > >for the given directory it does a depth first > search > >for each directory and file. > > > >so when i do this: > > > >find(sub{ return if -d; print "file"}, > >"/example_dir"); > > > >it should print as many "file" as I have in > >/example_dir. Am I right? > > It sometimes helps with File::Find to actually make > a separate > sub for the found sub. > > #!/usr/bin/perl > use File::Find; > > my $base_dir = '.'; > > find( \&found, $base_dir); > > sub found{ > return if -d; > print "$File::Find::name\n"; #name with full > path > } > __END__ > > > Always post working snippets, so we know exactly > what > you are doing. > > > > -- > I'm not really a human, but I play one on earth. > http://zentara.net/japh.html > > -- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > <http://learn.perl.org/> > <http://learn.perl.org/first-response> > > __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>