http://www.perlmonks.org?node_id=932521


in reply to Re^3: print last array element without a new line
in thread print last array element without a new line

That means you had a carriage return in the middle of the line.

A better solution would be to change

chomp(my $record = $_);
to
s/\r?\n//; my $record = $_;
or even
s/\s+\z//; my $record = $_;