Andrej Kastrin wrote:
Hi all,
I have the file, which looks like:
*RECORD*
*ID*
001
*TITLE*
Here is title number one.
*ABSTRACT*
First sentence of the abstract. Second sentence of the abstract...
Second line of the abstract.
*RECORD*
*ID*
002
*TITLE*
Here is title number one.
*ABSTRACT*
First sentence of the abstract. Second sentence of the abstract...
Second line of the abstract.
Is there any simple way to transform this file to look like:
*RECORD*
*ID* 001
*TITLE* Here is title number one.
*ABSTRACT* First sentence of the abstract. Second sentence of the
abstract. Second line of the abstract.
A one-liner:
$ perl -lp0e 's/\n(?!\*[A-Z]+\*)/ /g' myfile.dat
How it works:
1. Read input in "paragraph mode" (-0) option
2. Join any line that does not begin with *LETTERS* with the preceding line.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>