On Thu, 15 Aug 2002, Priss wrote: > I have amended the first few lines, this works but I > wonder if this bad... > > Priss > > while (<>) > { > /(\S+)/ > and $seen_in_file1{$1} += 1;
If the line that is being read is of the form word1 word2 $1 will only contain 'word1'. \S matches a non-whitespace character. > push @tmp, $_; > } > open (FILE, @tmp); This is not the correct way to open a file > > while (<FILE>) If you had enabled warnings in your program this will give a message like this readline() on closed filehandle FILE ... You might also want to take a look at File::Compare and Text::Diff. File::Compare is available with the standar distro, Text::Diff will have to be downloaded from cpan. http://search.cpan.org/author/RBS/Text-Diff-0.34/ A crude soln for your problem This will print lines in file2 not present in file1 #!/usr/bin/perl -w use strict; my %seen_in_file1; open (FILE1, "file1") or die "Cannot open file1: $!\n"; while (<FILE1>) { chomp; $seen_in_file1{$_}++; } close (FILE1); open (FILE2, "file2") or die "Cannot open file2: $!\n"; while (<FILE2>) { chomp; next if ($seen_in_file1{$_}); print "$_\n"; } close (FILE2); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]