The "selected_name" variable is local to the block of the "each" 
iterator. You have to define it outside the block:

def default_person(excel_value, person_list)
  selected_name = nil
  person_list.each do |name|
    ...
  end
  return selected_name
end

It's probably even better to use Enumerable#find:

def default_person(excel_value, person_list)
  person_list.find do |name|
    name.split.any? do |name_part|
      ...
    end
  end
end

-- 
Posted via http://www.ruby-forum.com/.