in reply to Does the output exist in a hash or array?
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; } } } } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Does the output exist in a hash or array?
by Light (Initiate) on Mar 20, 2012 at 09:57 UTC |
In Section
Seekers of Perl Wisdom