#!/usr/bin/perl -w my @L = (); my @R = (); my $file = "< SqlResults_full"; open(DATA, $file) or die "Can\'t open " . $file . " for output : $!"; while() { # BUILD @LIST chomp; next unless $_; my @Line = split ',', $_; if($Line[4] ne '--') { # 5th value real? push @R, \@Line; } elsif($Line[1] ne '--') { #2nd value real? push @L, \@Line; } } $\="\n"; print "R ".scalar(@R); print "L ".scalar(@L); print "TOTAL LINES ".( @R + @L ); use Data::Dumper; COMPARE(\@L,\@R); sub COMPARE { my( $L, $R ) = @_; my @Ret = (); my %L = map { $_ => $_; } 0..$#$L; my %R = map { $_ => $_; } 0..$#$R; for my $I(0..$#$R ) { for my $J(0..$#$L ) { if($R->[$I]->[4] eq $L->[$J]->[1]) { next unless exists $L{$J}; delete $L{$J}; delete $R{$I}; print join ',', @{ $R->[$I] }[4,5], @{ $L->[$J] }[1,2]; last; } } } print join ',', @{ $R->[$_] }[4,5,0,0] for keys %R; print join ',', @{ $L->[$_] }[0,0,1,2] for keys %L; }