I have 4 files, each file I read into it's own array. From there i then compare files A, B and C to each other. At each step I print out a list of numbers which are missing.
Compare A to B then B to A Print list of files found in A and not B and vise versa
Compare A to C then C to A Print list of files found in A but not C and vise versa
Compare B to C and C to B Print list of files found in B but not C and vise versa
Then I must take the values from these comparisons and compare them to file D print only the files that are not found in file D
Here is the code I have so far. I just think that there could be a better way of doing this and I would like some assistance with this.
[CODE]
sub compare {
my ($nf, $of, $inf, $infw) = @_;
open NF, $nf or die $!;
my @note_file = <NF>;
close NF;
open OF, $of or die $!;
my @order_file = <OF>;
close OF;
open INF, $inf or die $!;
my @invoice_file = <INF>;
close INF;
open INFW, $infw or die $!;
my @invoicefw_file = <INFW>;
close INFW;
my $lc1 = List::Compare->new(\@note_file,\@order_file);
my @unique_in_note_file = $lc1->get_unique;
my @unique_in_order_file = $lc1->get_complement;
print "The following files exist only in the Brighton-Note file and not in the Brighton-Order file : " . "\n\n" . join("\n", @unique_in_note_file) . "\n" if(scalar(@unique_in_note_file) > 0);
print "The following files exist only in the Brighton-Order file and not in the Brighton-Note file : " . "\n\n" . join("\n", @unique_in_order_file) . "\n" if(scalar(@unique_in_order_file) > 0);
my $lc2 = List::Compare->new(\@note_file,\@invoice_file);
@unique_in_note_file = $lc2->get_unique;
my @unique_in_invoice_file = $lc2->get_complement;
print "The following files exist only in the Brighton-Note file and not in the Web-Sales file : " . "\n\n" . join("\n", @unique_in_note_file) . "\n" if(scalar(@unique_in_note_file) > 0);
print "The following files exist only in the Web-Sales file and not in th Brighton-Note file : " . "\n\n" . join("\n", @unique_in_invoice_file) . "\n" if(scalar(@unique_in_invoice_file) > 0);
my $lc3 = List::Compare->new(\@order_file, \@invoice_file);
@unique_in_order_file = $lc3->get_unique;
@unique_in_invoice_file = $lc3->get_complement;
print "The following files exist only in the Brighton-Order file and not in the Web-Sales file : " . "\n\n" . join("\n", @unique_in_order_file) . "\n" if(scalar(@unique_in_order_file) > 0);
print "The following files exist only in the Web-Sales file and not in th Brighton-Order file : " . "\n\n" . join("\n", @unique_in_invoice_file) . "\n" if(scalar(@unique_in_invoice_file) > 0);
my $lc4 = List::Compare->new(\@unique_in_note_file,\@invoicefw_file);
my @unique_in_notefw_file = $lc4->get_unique;
my @unique_in_invoicefw_file = $lc4->get_complement;
print "The following files exist only in the Brighton-Note file and not in the Web-SalesFW file : " . "\n\n" . join("\n", @unique_in_notefw_file) . "\n" if(scalar(@unique_in_notefw_file) > 0);
print "The following files exist only in the Web-SalesFW file and not in th Brighton-Note file : " . "\n\n" . join("\n", @unique_in_invoicefw_file) . "\n" if(scalar(@unique_in_invoicefw_file) > 0);
my $lc5 = List::Compare->new(\@unique_in_order_file,\@invoicefw_file);
my @unique_in_orderfw_file = $lc5->get_unique;
@unique_in_invoicefw_file = $lc5->get_complement;
print "The following files exist only in the Brighton-Order file and not in the Web-SalesFW file : " . "\n\n" . join("\n", @unique_in_orderfw_file) . "\n" if(scalar(@unique_in_orderfw_file) > 0);
print "The following files exist only in the Web-SalesFW file and not in th Brighton-Order file : " . "\n\n" . join("\n", @unique_in_invoicefw_file) . "\n" if(scalar(@unique_in_invoicefw_file) > 0);
}