http://www.perlmonks.org?node_id=1005332


in reply to Replacing If Elsif Else with Hash

This will return 'grey' if you use a severity not defined in the hash:
my %bkcolor = ( 'Extreme' => 'red', 'Severe' => 'orange', 'Moderate' => 'yellow', 'Minor' => 'green', ); my $background = $bkcolor{$severity} // 'grey';