in reply to Delete the line

Your example is wrong, you seem to have looked at name2 for the elimination decision.

For the printing you might take a look at Text::Table which will output your table nicely formatted