Unfortunately some problems have slipped through because your code doesn't use strict; If you did that you'd see that the $line3 variable is undefined, and others lack lexical scoping.
Update:
Felt a bit guilty for the brevity of my original answer, so here is a quick example of code that works to produce the output you were expecting. It may need some tweaking as you see fit
use strict; use warnings; # Load the acceptable ids from file2 into a hash my %ids; open my $idfile, '<', 'file2' or die $!; for (<$idfile>) { $ids{$1} = 1 if m/Accept\s+=>\s+(\S+)/; } close $idfile; # Scan file1 printing each line where the ID matches one found in our +hash open my $datafile, '<', 'file1' or die $!; for (<$datafile>) { chomp; my ($id) = m/ID\s+(\S+)/; print "$_\n" if exists $ids{$id}; } close $datafile;
Output:
ID John06/ext $work(b05bfn00ld0p7)/b05bfn00ld0p7 ; #<= b05bfn00ld0s0 S +ize:INFINITY ID lily099/poli $work(b05bfn00ld0p7)/b05bfn00ld0p7 ; #<= b05bfn00ld0s0 + Size:INFINITY ID lily099/poli $wwrk(b05bfn00ld0p8)/b05bfn00ld0p8 ; #<= b05bfn00ld0s0 + Size:INFINITY
In reply to Re: Perl: How to print unmatched data after comparison of two files?
by Loops
in thread Perl: How to print unmatched data after comparison of two files?
by WWq
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |