I am having a file f1.txt which contains below text
abc
123
456
abc
456
343
abc
asd
23d
I want output of my regex to be
Every abc should start with new line, with all else (should be separated by | symbol) up to the next abc on it
abc|123|456
abc|456|343
abc|asd|23d
I tried below regex which is not producing expected result.
perl -p -e 's/\n(?!abc)/|/g' f1.txt
What will be the correct regex?, what i am missing? Thanks