What have you tried? What didn't work? See How (Not) To Ask A Question. Without seeing code, we can't effectively help you.
You can deal with the searching part of your problem fairly easily using a hash of hashes - see perlreftut and perllol.
I attempted to follow your spec, but do not get your output from following your described algorithm. For example, according to the rule you used to eliminate Temp1 A code1 2, Temp3 C code1 1 should be eliminated as well. I've attached the code I wrote. As this clearly does not meet your spec, you can either revise the code yourself or clarify where my algorithm and yours differ.
#!/usr/bin/perl
use strict;
use warnings;
my %test1;
open my $fh1, '<', 'test1.txt' or die "Open fail: $!";
while (<$fh1>) {
my ($temp, $letter, undef, $number) = split;
$test1{$temp}{$letter}{$number} = 1;
}
open my $fh, '<', 'test.txt' or die "Open fail: $!";
while (<$fh>) {
my ($temp, $letter, undef, $number) = split;
unless (defined $test1{$temp}{$letter}{$number}) {
print;
}
}
outputs
Temp2 B code1 2
Temp3 A code1 4
Temp3 B code1 4
Temp3 C code1 4
|