in reply to if statement consolidation
You can always do the data-driven approach, for example
my %inits = ( 1 => [1, 0, 9], 2 => [2, 1, 10], 3 => [3, 0, 11], # rest of the values go here ); if ($inits{$h}) { my @i = @{ $inits{$h} }; $j = $h + $i[0]; $p = $i[1]; $v = $i[2]; }
Or even
my %inits = ( 1 => [2, 0, 9], 2 => [5, 1, 10], 3 => [8, 0, 11], # rest of the values go here ); ($i, $p, $v) = @{$inits{$h}} if $inits{$h};
|
|---|