if ($answer =~ /^P/i) { ## Code for P here } ## Add some elsifs if > 2 choices else { ## No need to check the final letter ## Code for Q here }