$$output .= $line;
should do the trick, you forgot to dereference the reference to the scalar. For the list reference, you correctly used @$output though.
Yup, a guy across the room just explained it. Finally getting to grips with all this referencing business. Also figured out that I should be using ref() rather than my dodgy 'assign reference to a string and test that' business with the '$test' variable.