#!/usr/bin/perl -w use strict; my $file = "< SqlResults_full"; my @leftarray; my @rightarray; my @temp; my @left; my @right; my $j = 0; my $k = 0; open(DATA, $file) or die "Can\'t open " . $file . " for output : $!"; while(){ if (/^--,.*,--,--,--$/){ chomp; my $leftline = $_; my @lefttemp = (split/,/, $leftline); my $leftcut = $lefttemp[0] . ", " . $lefttemp[1] . ", " . $lefttemp[2]; push(@leftarray, $leftcut); } elsif (/^--,--,--,--,.*$/){ chomp; my $rightline = $_; my @righttemp = (split/,/, $rightline); my $rightcut = $righttemp[3] . ", " . $righttemp[4] . ", " . $righttemp[5]; push(@rightarray, $rightcut); } } my $leftsize = @leftarray; print "Left side is " . $leftsize . "\n"; print "Right side is ". $rightsize . "\n"; for (my $rightcount=0;$rightcount < $rightsize;$rightcount++){ my @right = split (/,/, $rightarray[$rightcount]); for (my $leftcount=0;$leftcount < $leftsize;$leftcount++){ my @left = split (/,/, $leftarray[$leftcount]); if ($left[1] eq $right[1]){ print $leftarray[$leftcount] . ", " . $rightarray[$rightcount]. "\n"; splice(@rightarray, $rightcount, 1); $rightcount--; $rightsize--; splice(@leftarray, $leftcount, 1); $leftcount--; $leftsize--; }#if }#while print "\n"; }#while