Replacement of sed with perl

Hi using the below cmd i am identifying wheether last character in each line in thousands of files as semicolon or not.If last character is semicolon i am removing semicolon .If last character is not semicolon then i am appending next line to present line .

For example my input file consists of

ABC|FGH|HJK|JKK;
BHJ|AAA|BBB|L
NNNN|JJJJ|LLLL;
JJJJJJ;
out put file consists of
ABC|FGH|HJK|JKK
BHJ|AAA|BBB|L NNNN|JJJJ|LLLL
JJJJJ
I am achieving the above requirement using sed as below

sed -e :a -e '/;$/!N;s/\n//; ta' -e 's/;$//' file

but i have thousands of files in one directory its consuming more and more time .

Can anyone replace the above requirement in perl with xargs

like xargs perl option

cn anyone suggest the easiest way without looping

how about sed:

sed -e :a -e '/$;/N; s/\\\n//; s/$;//; ta'  oldfile > newfile

Hi Jim ,

The above code works with sed but it is consuming too much time ..can you provide the same with perl syntax.
THe functionality is it has to identify last character in each line of all files as semicolon.if it founds as semicolon it has to replace with blank space otherwise need to append next line with present one.

see your other thread

cn anyone provide me the solution for replacing sed with perl in the above