print "@data";
This is your problem. Consider this code:
$ perl -E'@a=qw/1 2 3/; print "@a"'
1 2 3
You wanted to print your lines joined by empty string, but "@array" joins array elements with space (read
$" for more info on that). Your original, commented-out approach is better: just read your file by, say, 10 kilobytes and immediately send the data to client:
{
local $/ = \10240;
print while <$peunter>;
}
In this example I tell Perl to read files with diamond operator (<$filehandle>) by 10240 bytes (
$/) and loop printing the file pieces until I reach end-of-file.
Edit: corrected typo