alot of the monks already suggested good ways to do this.
but, if you're still wondering what's going on in your code,
the shift operator removes elements from @name.
that means the second time through the loop, @name is empty. and nothing is printed.