I would maintain a hash of samples you have already seen. That way you could check that hash to see if you've already printed that sample before or not.
I'm a little uncertain though. Do you want only one result per sample? Or any unique sample/tab3/tab23 combination? The following assumes that you only want one result per sample...
my %seen; while (<BATCH>) { chomp; s/\r//; my $filename = $_; $out_name = $filename; $out_name =~ s/\.txt//; $out_dir_name = "apt_SNPCall_".$out_name; foreach my $lf (@list_files){ open (SAMPLE, "$out_dir_name/birdseed-v2.report.txt") || die "Erro +r to open: $!"; while (<SAMPLE>) { chomp; my @tab = split("\t", $_); if ($tab[0] eq $lf){ my $sample = $lf; $sample =~ s/\.CEL//; if (!exists $seen{$sample}) { print $sample."\t".$tab[2]."\t".$tab[22]."\n"; $seen{$sample} = 1; } } } } }
In reply to Re: Does the output exist in a hash or array?
by Riales
in thread Does the output exist in a hash or array?
by Light
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |