use warnings; use strict; my %drinkType = ('coffee' => 'non alky', 'beer' => 'alky', 'whisky' => 'proper alky'); my $drink; my $punter = 'coffee'; if (exists $drinkType{$punter}) { $drink = $drinkType{$punter}; } else { $drink = 'unknown'; } print $drink;