Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: if statement consolidation

by moritz (Cardinal)
on Jun 27, 2012 at 15:45 UTC ( #978705=note: print w/ replies, xml ) Need Help??


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};


Comment on Re: if statement consolidation
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://978705]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2014-12-26 02:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (164 votes), past polls