"John W. Krahn" wrote: > > Barbara Green wrote: > > > > Hi Folks > > Hello, > > > I'm new to Perl, just a few days into it. I would like to know now I > > can search all files on a server > > perldoc File::Find > > > for names or numbers > > In the file name or in the file itself? > > perldoc perlre > perldoc perlretut > perldoc -f open > perldoc perlopentut > perldoc perlsyn > > > and have perl make > > a list of the found files. > > perldoc perldata > > Here is an example of what your program may look like: > > #!/usr/bin/perl > use warnings; > use strict; > use File::Find; > > my $dir_to_search = '/some/dir'; > my $name = 'somename'; > my $number = 876; > my @list_of_files; > > find( sub { > # want files only > return unless -f; > # put current file name into @ARGV > local @ARGV = $_;
Oops, that should be: local ( @ARGV, $_ ) = $_; > while ( <> ) { > # search through contents of current file > if ( /$name/ or /$number/ ) { > # store full file path and return for next file > push @list_of_files, $File::Find::name; > return; > } > } > }, $dir_to_search ); > > # now do something with @list_of_files > > __END__ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>