Well, are you trying to find several patterns (file1, file2 etc.) in all 
files in $dirname, or are you trying to determine wether those file1, file2 
etc. exists in $dirname directory? it's not clear from your code....

anyway, one more note: you don't need to test 'defined(@files=readdir DIR)', 
as it's sufficient to test '@files = readdir DIR'.

On Monday 16 July 2001 10:11, Groove Salad wrote:
> Hello Everyone:
>
> I'm trying determine the best way to check if a file name is contained
> within a couple of larger files. I can do a grep from the command line
> but, what's the fun of that!?  Plus there's  about a hundred files which
> would be tedious.
>
> Here's my coding attempt:
>
> $dirname = "/var/tmp/allfiles";
> @filenames = qw(file1 file2 file3 file4 file5);
> opendir(DIR, $dirname) or die "Can't open $dirname: $!";
>      while (defined(@files = readdir(DIR)))
>      {
>       foreach my $searchfile ( @files )
>        {
>               next if $searchfile =~ /^\.\.?$/;
>                        open(FH, "<$dirname/$searchfile") or die;
>
>                       while(<FH>)
>                       {
>                          foreach my $foundfile ( @filenames )
>                          {
>                               print "$foundfile\n" if -T "$dirname/$searchfile";
>                          }
>                       }
>               close(FH);
>       }
>     }
> closedir(DIR);
>
>
> So if I have only five files to check against a hundred I'm lost. Please
> help!
>
> George Sala

-- 
Ondrej Par
Internet Securities
Software Engineer
e-mail: [EMAIL PROTECTED]
Phone: +420 2 222 543 45 ext. 112


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to