$ perl -wle '$_="a\nbc\nd";s{$}{
}gm; print' a
bc
d