You could use a hash to get from file2, the files parameter, you want and using a while loop, check if these files parameter gotten from file2 exists in file1. if so print the whole line of file1.
Like this:
Update:use warnings; use strict; use Inline::Files; my %hash; while (<DATA2>) { next if /^\s*$/; $hash{ ( split /\s+?/, $_ )[2] } = undef; } while (<DATA1>) { next if /^\s*$/; if (/^.+?\s(.+?)\s/) { print $_ if exists $hash{$1}; } } __DATA1__ ID alan135 /xkr $work(b05bfn00un0c3) / b05bfn00un0c3; #<= b05bfn00un +0d0 Size:5848.270996 ID John06 /ext $work(b05bfn00ld0p7) / b05bfn00ld0p7; #<= b05bfn00ld +0s0 Size:INFINITY ID lily099 /poli $work(b05bfn00ld0p7) / b05bfn00ld0p7; #<= b05bfn00 +ld0s0 Size:INFINITY ID sam012 /pp $work(b05bfn00ld0p7) / b05bfn00ld0p7; #<= b05bfn00l +d0s0 Size:INFINITY ID lily099 /poli $wwrk(b05bfn00ld0p8) / b05bfn00ld0p8; #<= b05bfn00 +ld0s0 Size:INFINITY ID Steve9018 $work(b05bfn00ld0p7) /b05bfn00ld0p7; #<= b05bfn00 +ld0s0 Size:INFINITY __DATA2__ Accept => John06 / ext Max Accept => vivian788 / ppr Maxcap Accept => suzan645 / pp Min Accept => lily099 / poli Max Accept => Nick5670 / uu Max Accept => Anne309 / pej Min
In reply to Re: Perl: How to print unmatched data after comparison of two files?
by 2teez
in thread Perl: How to print unmatched data after comparison of two files?
by WWq
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |