in reply to Keeping the first occurence of a pattern, and removing the other occurences

Bear in mind that the "^L" that you are seeing is probably a text representation of a form feed control character so you might need to change your input record separator to something like "\cL", IIRC.

Cheers,

JohnGG