in reply to How is outputting to an array different from outputting to a file
Observation: You're not chomp'ing in the first case, and over-chomp'ing in the second.