in reply to text reformatting woes

You can avoid spliting and rejoining @l3 by saying: ($l1,$l2,$remainder) = split /\n/, $i, 3; and then printing $remainder instead of join("\n",@l3)

See split for more on how the limit parameter works.