I can't help with algorithm either but I would offer some observations.

You would use a next statement if your code is in a while or for loop. Is this the case?

On a minor note, you test $best_X <= 100 twice. You could refactor it to only test it once. If the condition changes you only have one thing to change (same applies to $best_Y).

In your $best_X tests you test $block1 and $block2 and in the $best_Y tests you test $block1 twice. Is that what you intended? This may be an over enthusiastic search for symetry on my part. :-)

There appears to be an unmatched closing brace.

But, but, but... The main thing is to test it rigourously. With all possible values for every variable and in all possible combinations. And then some. Then you'll know if you are heading in the right direction.

I've taken the liberty of tweaking the format a bit.

#! /usr/bin/perl use strict; use warnings; my ( $best_X, $best_Y, $block1, $block2, $counter, $tq, $pp, $pp2, $pz, $pz2, $position1, $position2, $resH, $nTE2 ); #keep counts of matches to check for unique match $counter++ if ( $best_X <= 110 && $block1 <= 110 || $best_Y <= 110 && $block2 <= 110 ); if ($counter == 1){ $tq = "unique_match"; } elsif ($best_X <= 100){ if ($block1 <= 100){ $pp = "best_match+TE"; } elsif ($block2 <= 50 && $position2 < 5){ $pp2 = "best_match-TE"; } } else{ next; # are we in a loop? } if ($best_Y <= 100){ if ($block1 >= 70){ $pz = "best_match+TE"; } elsif ($block1 <= 50 && $position1 >= 50){ # block2? $pz2 = "best_match-TE"; } } else{ next; } #} perl complains about this one $resH = $tq; if ($pp eq $pz){ $resH = "best_match+TE"; } elsif ($nTE2 eq $pp2 || $nTE2 eq $pz2){ $resH = "best_match -TE" }

In reply to Re: I need help with a bunch of "if/elsif statements (comparisons)" by wfsp
in thread I need help with a bunch of "if/elsif statements (comparisons)" by erons

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.