in reply to if statement consolidation
If your Perl is relatively modern, you could look into given/when. Another idea might to write a look-up hash and draw from that. I'm not saying it's the best idea, but at least it's an idea. Update: and a rather popular idea, too.
my %values_for_h => 1 => [1, 0, 9], 3 => [2, 1, 10], 5 => [3, 0, 11], 7 => [4, 1, 11], 10 => [5, 0, 5], 12 => [6, 1 6], 14 => [7, 0, 7], 16 => [8, 1, 8] ); if (exists $values_for_h{$h}) { $j = $h + $values_for_h{$h}->[0]; $p = $values_for_h{$h}->[1]; $v = $values_for_h{$h}->[2]; }
|
|---|