$|=1; # So it works in the Open Perl IDE

%names = ("Bill" => "Clinton",      # use the nice way of defining a hash
          "Barack" => "Obama",
          "George" => "Bush",
          "Jimmy" => "Carter");

print "Type in a first name:\n";
$n = <STDIN>;
chomp $n; # remove the \n. Important or the string won't match!
if (exists $names{$n}){  # check if that entry exists
  print "$n" . "'s last name is $names{$n}";
}
else {
  print "I don't know that person!";
}
