That means you had a carriage return in the middle of the line.
A better solution would be to change
tochomp(my $record = $_);
or evens/\r?\n//; my $record = $_;
s/\s+\z//; my $record = $_;
In reply to Re^4: print last array element without a new line
by ikegami
in thread print last array element without a new line
by sy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |