Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Does the output exist in a hash or array?

by Riales (Hermit)
on Mar 19, 2012 at 17:11 UTC ( #960447=note: print w/replies, xml ) Need Help??

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/") || 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

    I only want the first result of the sample, so if the sample already exists in the output I guess, I want to skip that sample and go to the next line.

    Thanks for your help.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://960447]
[Corion]: We-ird - I hadn't known this, but Ingress and Pokemon Go (both AR games in the real world where you run around) switched from using Google Maps to OpenStreetMaps, which is great. But I wonder why, as Ingress is (was?) owned by Google/Alphabet. But ...
[Corion]: ... maybe not wholly owned, or the load on Google Maps was too high?!

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2018-03-19 09:06 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (236 votes). Check out past polls.