Karyn Williams wrote:
> Below is code that I found on the web that I slightly modified. I am
> trying to create a script to remove from a file (tlist) the items in
> another file (tnames). This works but I have multiple files (tlist) I
> need to check against. I'm not sure how/where to put the loop and
> would appreciate any help. I am also wondering why the hash ? Does it
> work better in  the script than an array and what are the keys in
> this case as the files (both) are just lists of e-mail addresses.
> 
        Are all the files w/in the same directory or scattered? Are there 2 or 
500?

If only a few, then could create an array which has the filenames:

my @MyTlist = qw (file1 file2 file3 file4);
Now you could loop off this like:
 foreach my $file2 ( @MyTlist ) {
   open (FILE2, $file2 ) or die "$!";
   while (<file2 >) {
           chomp;
           push @missing,$_ unless (exists($compare{$_}));;
   }
   close(file2 );
  }

Now you can write out all that are not true.

If there are a large number and say in one directory, then use opendir, readdir 
to get the files you want and use a simliar setup as above.

Wags ;)
> #!/bin/perl
> 
> my %compare = ();
> open (file1, "/usr/local/tools/tnames") or die "$!";
> while (<file1>) {
>         chomp;
>         $compare{$_}++;
> }
> close(file1);
> 
> open (file2, "/usr/local/tools/tlist") or die "$!";
> while (<file2>) {
>         chomp;
>         push @missing,$_ unless (exists($compare{$_}));;
> }
> close(file2);
> #print "$_\n" for @missing;
> 
> open (file3, ">/usr/local/tools/tlist1") or die "$!";
> print file3 join("\n",@missing);
> print file3 ("\n");
> close (file3);
> 
> 
> TIA
> 
> --
> 
> Karyn Williams
> Network Services Manager
> California Institute of the Arts
> [EMAIL PROTECTED]
> http://www.calarts.edu/network



*******************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
*******************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to