while(<DATA>){ s/([A-Z][a-z]+)\s([A-Z][a-z]+)/$2, $1/; # Reverse first and last names print; } __DATA__ S B B B A C N C J D K E