in reply to multi column multi file comparison
What have you tried? There is a neat trick you can use in Perl to make it easy to mock up a few files that may help you get started on a solution. Consider:
use strict; use warnings; my $file1Str = <<FILEDATA; Alex 3 44 Barry 2 44 James 6 45 Drew 9 43 Alex 124 175 FILEDATA my $file2Str = <<FILEDATA; James 1 22 Alex 89 120 Alex 134 155 Barry 12 24 FILEDATA my $file3Str = <<FILEDATA; Alex 154 174 James 29 45 Drew 19 54 Drew 139 154 FILEDATA open my $fileIn, '<', \$file1Str; print "Prim: $_" for <$fileIn>; close $fileIn; for my $secFile ($file2Str, $file3Str) { open my $secIn, '<', \$secFile; print "Sec: $_" for <$secIn>; }
Prints:
Prim: Alex 3 44 Prim: Barry 2 44 Prim: James 6 45 Prim: Drew 9 43 Prim: Alex 124 175 Sec: James 1 22 Sec: Alex 89 120 Sec: Alex 134 155 Sec: Barry 12 24 Sec: Alex 154 174 Sec: James 29 45 Sec: Drew 19 54 Sec: Drew 139 154
The trick is using a string as an input file by passing a reference to it in place of a file name in the open statement. That allows you to easily include several tests "files" in your source code so you can easily play around with test data. It also makes it really easy for us to reproduce your results when you ask a question concerning your code.
|
|---|