in reply to Join and append to last element?

Just add an empty string at the end of the list of things to join:

my $result = join("\n", @lines, "");