%names = ("Barak" => "Obama",
          "George W." => "Bush",
          "Bill" => "Clinton",
          "George" => "Bush",
          "Ronald" => "Reagan",
          "Jimmy" => "Carter");

@first = keys %names;
@sorted = sort @first;

$i = 0;
foreach $key (@sorted){
  $run = $run + 1;
  print "Pair $run: Checking $key\n";
  $len = length $names{$key};
  push @lengths,$len;
}


$sum = &sum(@lengths);
print "The presidents' last names have $sum letters!";


sub sum {
  my @lengths = @_;
  my $sum;
  foreach $e (@lengths){
    $sum = $sum + $e;
  }
  return $sum;
}
