#! perl -slw use strict; my $currentFile = 'current.dat'; my $masterFile = 'master.dat'; my $matched = 'matched.dat'; my $nomatch = 'nomatch.dat'; my %current; open CURRENT, '<', $currentFile or die $!; m[^ ( [^|]+ ) \| ]x and $current{ $1 } = $_ while ; close CURRENT; open X, '>', $matched or die $!; open Y, '>', $nomatch or die $!; open MASTER, '<', $masterFile or die $!; while( ) { if( m[^ ( [^|]+ ) \| ]x and exists $current{ $1 } ) { my $key = $1; my @master = split '\|', $_; my @current = split '\|', $current{ $key }; if( 6 == grep{ $current[ $_ ] eq $master[ $_ ] } 7, 14, 21, 30, 50, 119 ) { print X; ## Matched records } else { print Y; ## non-matched records } } } close MASTER; close X; close Y;