in reply to Re: Hash - Compare - Multiple value keys
in thread Hash - Compare - Multiple value keys

Hi Mike, Thanks for the comment. In the inner loop, after the condition is met, I want to print the result only once. then the loop should continue to check other records to see if it can find the match. Here I have included a partial output of this code. I just need to print the first line. where col 1 and 4 pair and 2 and 3 pair. this is were the condition is met. Then it should find the next match before printing ~4000 junk comparisons.
CLS_S3_Contig10021 349 349 CLS_S3_Contig10021 CLS_S3_Contig10021 898 349 CLS_S3_Contig10021 CLS_S3_Contig10021 524 349 CLS_S3_Contig10021 CLS_S3_Contig10021 365 349 CLS_S3_Contig10021 CLS_S3_Contig10021 373 349 CLS_S3_Contig10021 CLS_S3_Contig10029 857 349 CLS_S3_Contig10021 CLS_S3_Contig10029 482 349 CLS_S3_Contig10021 CLS_S3_Contig10029 676 349 CLS_S3_Contig10021 CLS_S3_Contig10029 153 349 CLS_S3_Contig10021 CLS_S3_Contig10031 797 349 CLS_S3_Contig10021 CLS_S3_Contig10031 587 349 CLS_S3_Contig10021 CLS_S3_Contig10031 227 349 CLS_S3_Contig10021 CLS_S3_Contig10031 314 349 CLS_S3_Contig10021 CLS_S3_Contig10031 605 349 CLS_S3_Contig10021 CLS_S3_Contig10031 257 349 CLS_S3_Contig10021 CLS_S3_Contig10031 212 349 CLS_S3_Contig10021 CLS_S3_Contig10031 857 349 CLS_S3_Contig10021 CLS_S3_Contig10031 635 349 CLS_S3_Contig10021 CLS_S3_Contig10031 188 349 CLS_S3_Contig10021 CLS_S3_Contig10031 410 349 CLS_S3_Contig10021 CLS_S3_Contig10031 806 349 CLS_S3_Contig10021 CLS_S3_Contig10040 439 349 CLS_S3_Contig10021 CLS_S3_Contig10051 719 349 CLS_S3_Contig10021 CLS_S3_Contig10051 92 349 CLS_S3_Contig10021 CLS_S3_Contig1006 279 349 CLS_S3_Contig10021 CLS_S3_Contig1006 240 349 CLS_S3_Contig10021 CLS_S3_Contig1006 168 349 CLS_S3_Contig10021 CLS_S3_Contig10070 196 349 CLS_S3_Contig10021 CLS_S3_Contig10072 882 349 CLS_S3_Contig10021 CLS_S3_Contig10072 685 349 CLS_S3_Contig10021 CLS_S3_Contig10072 892 349 CLS_S3_Contig10021 CLS_S3_Contig10072 237 349 CLS_S3_Contig10021 CLS_S3_Contig10072 858 349 CLS_S3_Contig10021 CLS_S3_Contig10083 868 349 CLS_S3_Contig10021 CLS_S3_Contig1010 774 349 CLS_S3_Contig10021 CLS_S3_Contig1010 613 349 CLS_S3_Contig10021 CLS_S3_Contig10134 452 349 CLS_S3_Contig10021 CLS_S3_Contig10157 545 349 CLS_S3_Contig10021 CLS_S3_Contig10157 500 349 CLS_S3_Contig10021 CLS_S3_Contig10157 875 349 CLS_S3_Contig10021 CLS_S3_Contig10157 404 349 CLS_S3_Contig10021

Replies are listed 'Best First'.
Re^3: Hash - Compare - Multiple value keys
by RMGir (Prior) on Sep 07, 2008 at 18:37 UTC
    So what's the purpose of $found?

    If all you need is to find out if this line matches criteria and do something based on that, that's pretty well what "if" statements are for...

    foreach $1 (sort keys %file1){ foreach my $position1 (@{$file1{$1}}){ foreach $contig_id(sort keys %hash_1){ foreach my $position (@{$hash_1{$contig_id}}){ if($1 =~ /^$contig_id/ && $contig_id=~ /^$1/ && $posit +ion1==$position) { print RESULTS "$position1\t$1\n"; } else { print "not matched\n"; } } } } }

    Mike