in reply to MySQL last name field

...use a foreach statement to split the names up so I could retrieve the last name
Don't underestimate the difficulty of this task. A simple-minded split on whitespace will probably get you no better than 75%. You may want to get help from a module like Lingua::EN::ParseNames.