in reply to regex replacement help

As of perl 5.10, you could use: s/~\K/\n/g
(may be a trivial use of \K :-) )