Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Replacing If Elsif Else with Hash

by johnfl68 (Scribe)
on Nov 24, 2012 at 04:59 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1005331]
Approved by frozenwithjoy
Front-paged by 2teez
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-05-30 10:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found