Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Replacing If Elsif Else with Hash

by johnfl68 (Beadle)
on Nov 24, 2012 at 04:59 UTC ( #1005331=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
            if ($severity eq "Extreme"){
            $background = "red";
            }
    ...
            else {
            $background = "grey";
            }
    
  2. or download this
        my %bkcolor = (
                "Extreme", "red",
                "Severe", "orange",
    ...
            );
    
        my $background = $bkcolor{$severity};
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1005331]
Approved by frozenwithjoy
Front-paged by 2teez
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (11)
As of 2017-01-18 14:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (161 votes). Check out past polls.