in reply to I need help with a bunch of "if/elsif statements (comparisons)"

I know this isn't very helpful, but if you could provide a little context and better formatting, we might be able to help factor that down a little. For example, I'm guessing some of these strings are going to be used after this bit of code, so I'm not sure which ones need to keep their values and which are just there for later comparisons, which could be written in many ways.

As it is, if it works, use it. If it's slow, benchmark it (and compare it with other code in the program to identify the bottleneck). Only then can you really determine whether changing it buys you anything.

  • Comment on Re: I need help with a bunch of "if/elsif statements (comparisons)"

Replies are listed 'Best First'.
Re^2: I need help with a bunch of "if/elsif statements (comparisons)"
by erons (Initiate) on Jan 27, 2010 at 16:36 UTC

    Hi, I only need to keep and print $resH, which holds the string after the final 'comparison'

    use strict; if($best_X <= 110 && $block1 <=110 || $best_Y <= 110 && $block2 <= 110 + ){#keep counts of matches to check for unique match $counter++;} if($counter == 1){ $tq = "unique_match" }elsif($best_X <= 100 && $block1 <= 100){ $pp = "best_match+TE" }elsif($best_X <= 100 && $position2 < 5){ if($block2 <= 50){ $pp2 = "best_match-TE"} }else{next} if($best_Y <= 100 && $block1 >= 70){ $pz = "best_match+TE" }elsif($best_Y <= 100 && $position1 >= 50){ if($block1 <= 50){ $pz2 = "best_match-TE"} }else{next} }
Re^2: I need help with a bunch of "if/elsif statements (comparisons)"
by Anonymous Monk on Jan 27, 2010 at 16:26 UTC

    It also looks like the OP has HTML tags mixed into the code.

    Erons: Copy and paste the code directly from your source into the <code></code> tags to prevent any typos and ensure that the code will still work.